1
我将我的网站从本地移动到服务器,我的.htaccess中的重写规则不起作用。无法打开需要'重定向:/index.php'(include_path ='。:/ usr/lib64/php:/ usr/lib/php')在Unknown 0行
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^contact-us$ index.php?p=2
</IfModule>
这就是我在我的.htaccess中。
但我确定.htaccess被服务器识别(我通过在.htaccess中放入一些垃圾进行测试 - 我得到了服务器错误)。
为了进一步诊断问题,我修改我的.htaccess象下面这样:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^contact-us$ index.php?p=2
RewriteRule contact-us$ index.php?p=2
RewriteRule ^contact-us index.php?p=2
RewriteRule contact-us index.php?p=2
</IfModule>
现在,我得到一个奇怪的错误,而访问我site.com/contact-us
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'redirect:/index.php' (include_path='.:/usr/lib64/php:/usr/lib/php') in Unknown on line 0
该错误来自PHP。我不知道你的脚本是做什么的,但是检查文件权限(例如会话文件位置,编译模板/缓存文件等)。 **但通常情况下:**检查重写是否有效 - 进行临时重定向,以便网址也可以在浏览器中更改,例如'RewriteRule^contact-us $ index.php?p = 2 [R = 302,L]' – LazyOne 2012-04-02 14:56:29
你可以直接打开http://你的主机名/ index.php?p = 2吗?它似乎汤姆我喜欢这个.htaccess文件所在的目录中没有index.php。 – 2012-04-02 20:00:23