我从其他人手中接管的网站使用索引页面上的加载程序,根据请求的URL拉入正确的页面。例如,如果您请求http://example.com/services它知道从"视图"文件夹中提取services.php页面。它使用htaccess用以下重写URL
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/(.*)]+)$ ?$1 [L]
RewriteRule ^([^/(.*)]+)/$ ?$1 [L]
这一切都很好,除了当你只需转到http://example.com在这种情况下,它抛出500错误。如果我尝试访问/索引,它会按预期提取相应的索引视图。
我的主机给我的错误日志(恐怕不多,500页中只有404页找不到)
[Wed Oct 29 15:51:41 2014] [error] [client 216.54.92.21] File does not exist: /home/hotwater/public_html/500.shtml
[Wed Oct 29 15:48:56 2014] [error] [client 216.54.92.21] File does not exist: /home/hotwater/public_html/500.shtml
[Wed Oct 29 15:48:47 2014] [error] [client 216.54.92.21] File does not exist: /home/hotwater/public_html/500.shtml
这个网站在以前的主机上运行,但当我们把它转移到新主机上时,主页坏了,我自己似乎无法运行。感谢您的帮助。
问题似乎出现在您的正则表达式中,并且是任何RewriteCond
的最后一个RewriteRule
。请改用此规则:
ErrorDocument 404 default
ErrorDocument 500 default
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?$ ?$1 [L,QSA]