Forum Moderators: open
I want a script that would redirect the visitors if they enter from strangeword.at to mysite.com. I read some old threads relating to this and someone suggested a 301 permanent redirection.
My question is would the 301 permanent redirection script solve this problem? If so how would I set it up? I am new to using .htaccess and any help that can be given to me on this subject would be appreciated.
The following code, added to your web root .htaccess file, will solve your problem. Replace quux-corp.org with your correct domain name. The dots should be escaped with preceding slashes exactly as shown, and only where shown.
# Redirect non-standard incoming domains to standard www.quux-corp.org
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.quux-corp\.org
RewriteRule ^(.*)$ http://www.quux-corp.org/$1 [L,R=permanent]
See this Introduction to mod_rewrite [webmasterworld.com] post for a lot of useful information and links to reference material.
HTH,
Jim
[edited by: jdMorgan at 5:28 am (utc) on Feb. 25, 2003]
When using that code I get a 500 Internal Server Error. Did I enter something wrong?
# Redirect non-standard incoming domains to standard www.mysite.com
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.mysite\.com
RewriteRule ^(.*)$ [mysite...] [L,R=permanent]