[removed] in .htaccess causes 500 server error (Re

2019-02-12 23:02发布

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)

3条回答
再贱就再见
2楼-- · 2019-02-12 23:51

I had same issue, for me this didn't work as well:

RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]

What worked for me is to remove the leading slash, and add soft tailing slash with ?, like this:

RewriteRule ^(page1.html)/?$ dir1/page.html [R=301,L]
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-02-12 23:53

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/

查看更多
迷人小祖宗
4楼-- · 2019-02-12 23:57

Changed all Redirect 301 rules to:

RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]

now working. But how does it work on production?

查看更多
登录 后发表回答