.htaccess 文件来实现 httpd.conf 更改
我需要对服务器的 httpd.conf 进行以下更改
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
AllowOverride All
AccessFileName .htaccess
但是,我被告知无法直接更改,因为它是 shell 服务器,因此需要通过 .htaccess 文件使用 mod_rewrite。
我现在的问题是,如何转换代码?我尝试到处搜索但找不到任何答案。抱歉,我是这个领域的新手。
非常感谢。
问候, 肖恩
I need to make the following changes to my server's httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
AllowOverride All
AccessFileName .htaccess
However, i was told that making direct change is not possible as it is a shell server so there is a need to use mod_rewrite via a .htaccess file.
My question is now, how do I convert the codes? I've tried searching everywhere but could not find any answer to this. Sorry that I am a newbie in this area.
Thank you very much.
Regards,
Sean
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。您的设置基本上指示 Apache 使用
.htaccess
作为每个目录的配置文件,并授予此类文件所有可用权限。显然:有趣的一点是,考虑到
.htaccess
已经是默认值,而其他指令是托管服务根据其策略授予或拒绝的,那么为什么您确实需要这些更改。You cannot. Your settings basically instruct Apache to use
.htaccess
as per-directory configuration file and grant such files all available permissions. Obviously:The interesting point is why exactly you need those changes, given that
.htaccess
is already the default value and the other directives are something the hosting services grant or deny according to their policies.据我了解,您的服务器设置为不允许您访问 httpd.conf,而是让您能够创建 .htaccess 文件来执行所需的 mod_rewrites。这是一个典型的场景。您无需向 httpd.conf 写入任何内容即可实现这一点。它已经为你做好了。
要创建 mod_rewrites,您需要使用任何文本编辑器创建一个 .htaccess 文件,该文件具有该名称且无扩展名,但前面带有句点 (.),并将其直接保存到您的域根目录,例如。 www.yourdomain.com/.htaccess
在此文件中,您将按照以下模式编写 mod_rewrite 代码:
RewriteCond 测试字符串cond_pattern
以下 mod_rewrite 代码通常与 WordPress 一起使用,以允许页面和帖子具有更合理的永久链接模式:
有关此主题的好文章可以在以下位置找到:fubra.com
I understand that your server is set to not allow you access to httpd.conf but rather gives you the ability to create .htaccess files to do your needed mod_rewrites. This is a typical scenario. You do not need to write anything to httpd.conf to make that happen. It is already done for you.
To create mod_rewrites you need to create an .htaccess file with any text editor with that name and no extension but with a preceding period (.) and save it to your domain root directly eg. www.yourdomain.com/.htaccess
Inside this file you would then write your mod_rewrite code following this pattern:
RewriteCond test_string cond_pattern
The following mod_rewrite code is oftentimes used with WordPress to allow pages and posts to have a more sensible permalink pattern:
A good article to read on this topic can be found at: fubra.com