Forum Moderators: phranque

Message Too Old, No Replies

500 server error on 301 redirect .htaccess

multiple domains on multiple directories

         

elgolden

9:31 pm on Dec 6, 2008 (gmt 0)

10+ Year Member



Hello every one

I was searching this great forum before i post but i didn't catch any answer for my problem, hope you can help me guys .

my websites are all hosted on a single hosting account , i have :
domain1.com pointed to public_html/index.html
domain2.com pointed to public_html/scriptxx/index.html

I got a new domain (domain3.com) and pointed to public_html/scriptxx/index.html .. where domain2.com is also pointed .

Now i want search engines to archive domain3 and to forward the domain2 PR to domain3 , so i created a new directory public_html/test-folder/ and pointed domain2 to it from my hosting panel , and was trying to implement a 301 in .htaccess.
The methods that i used :

RedirectMatch 301 ^(.*)$ http://www.domain3.com

RedirectMatch 301 (.*) http://www.domain3.com/

Redirect 301 / http://www.domain3.com

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.domain3.com/$1 [R=301,L]

But im always getting 500 server error with each one , so what's wrong with my code ?

Thank you very much.

[edited by: jdMorgan at 10:23 pm (utc) on Dec. 6, 2008]
[edit reason] De-linked URLs in code [/edit]

jdMorgan

10:22 pm on Dec 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer is in your server error log file, but I'll hazard a guess that you're getting a "Maximum server redirection limit exceeded" error. This is because you redirect any and all hostnames which resolve to this .htaccess file to domain3. But domain3 also resolves to this .htaccess. So when the client comes back with a new HTTP request using the new URL from your redirect, it gets redirected again. And again, and again, and again, until either the client (browser or robot) or the server gives up.

The solution is to use a RewriteCond on your RewriteRule, so that only domain2 requests get redirected to domain3:


RewriteCond %{HTTP_HOST} domain2\.com
RewriteRule (.*) http://www.domain3.com/$1 [R=301,L]

If that doesn't help, I suggest you thoroughly investigate the errors reported in your server error log -- That error log file is quite useful and specific in most cases.

Jim