.htaccess 中的重定向 301 导致 500 服务器错误(重定向到非 URL)
问题描述:
有这样的错误.
当将 Redirect 301
规则添加到 .htaccess
文件时,如:
When adding Redirect 301
rule to .htaccess
file like:
Redirect 301 "/page1.html" "/dir1/"
我的站点因 500 服务器错误而失败,并且在 apache 错误日志中出现此错误:
My site fails with 500 server error and in apache error log this error appears:
[Wed Mar 16 11:08:52 2011] [alert] [client 127.0.0.1] /home/htdocs/site.com/www/.htaccess: Redirect to non-URL
安装了Mod rewrite,也尝试提供不带引号的url.
在生产服务器上这个 .htaccess 工作正常,但在本地会导致麻烦
任何想法,请)
此规则有效
Redirect 301 "/page1.html" "http://www.site.com/dir1/"
但我需要一种提供相对路径而不是完整网址的方法(生产服务器就是这样工作的)
but I need a way to supply relative paths instead of full urls (production server works that way)
答
将所有 Redirect 301
规则更改为:
Changed all Redirect 301
rules to:
RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]
现在工作.但它如何在生产中发挥作用?
now working. But how does it work on production?