301 redirect in .htaccess causes 500 server error (redirect to non url)

have such an error.

When adding a Redirect 301 rule to a .htaccess file, for example:

 Redirect 301 "/page1.html" "/dir1/" 

My site crashes with an error of 500 servers and this error appears in the apache error log:

 [Wed Mar 16 11:08:52 2011] [alert] [client 127.0.0.1] /home/htdocs/site.com/www/.htaccess: Redirect to non-URL 

The mode rewrite was installed, they also tried to provide URLs without quotes.

On the production server, this .htaccess works fine, but for local reasons, problems

Any ideas please)


This rule works.

 Redirect 301 "/page1.html" "http://www.site.com/dir1/" 

but I need a way to provide relative paths instead of full URLs (the production server works this way)

+8
.htaccess apache2
source share
3 answers

All Redirect 301 rules Redirect 301 :

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

it works now. But how does it work in production?

+8
source share

I had the same problem for me. Adding "http://domain.com" before "/ mypage" worked; I am still testing to make it work without it, as is the case on my production server. So, my .htaccess in my local test environment went as follows:

BROKEN: Redirecting 301 / mypage / directory1 / sub-directory / mypage /

FIXED: 301 redirect http://mydomain.com/mypage http://mydomain.com/directory1/sub-directory/mypage/

+1
source share

I had the same problem, for me this did not work:

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

What worked for me: remove the leading slash and add a soft tail braid with?, For example:

 RewriteRule ^(page1.html)/?$ dir1/page.html [R=301,L] 
+1
source share

All Articles