.htaccess 中的重定向 301 导致 500 服务器错误(重定向到非 URL)
有这样的错误。
将 Redirect 301
规则添加到 .htaccess
文件时,例如:
Redirect 301 "/page1.html" "/dir1/"
我的网站因 500 服务器错误而失败,并且在 apache 错误日志中出现此错误:
[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 也已安装尝试提供不带引号的网址。
在生产服务器上,这个 .htaccess 工作正常,但在本地会导致麻烦
请有任何想法)
此规则有效,
Redirect 301 "/page1.html" "http://www.site.com/dir1/"
但我需要一种提供相对路径的方法完整网址(生产服务器以这种方式工作)
have such kind of error.
When adding Redirect 301
rule to .htaccess
file like:
Redirect 301 "/page1.html" "/dir1/"
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 is installed, also tried to provide urls without quotes.
On production server this .htaccess works fine, but on local causes troubles
Any ideas, please)
This rule works
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将所有
Redirect 301
规则更改为:现在有效。但它在生产中是如何运作的呢?
Changed all
Redirect 301
rules to:now working. But how does it work on production?
对于我来说,我遇到了完全相同的问题。在“/mypage”前面添加“http://domain.com”有效;我仍在测试让它在没有的情况下工作,就像在我的生产服务器上一样。所以我的本地测试环境中的 .htaccess 是这样的:
损坏:
重定向 301 /mypage /directory1/sub-directory/mypage/
已修复:
重定向 301 http://mydomain.com/mypage http://mydomain.com/directory1/sub-directory/我的页面/
For me, I had the exact same issue. Adding "http://domain.com" in front of "/mypage" worked; I am still testing to get it to work without, as is does on my production server. So my .htaccess on my local testing environment, went like this:
BROKEN:
Redirect 301 /mypage /directory1/sub-directory/mypage/
FIXED:
Redirect 301 http://mydomain.com/mypage http://mydomain.com/directory1/sub-directory/mypage/
我遇到了同样的问题,对我来说这也不起作用:
对我有用的是删除前导斜杠,并使用 ? 添加软尾斜杠,如下所示:
I had same issue, for me this didn't work as well:
What worked for me is to remove the leading slash, and add soft tailing slash with ?, like this:
请尝试一下,它按预期工作。
Please try this, it's working as expected.