Spinland Posted April 15, 2009 Posted April 15, 2009 (edited) I need to come up with the correct syntax for 301 re-directs to solve multiple issues. The canonical domain name I want to establish is www.spinland.biz. I know how to come up with the code for redirecting 'spinland.biz' to 'www.spinland.biz' but at the same time I need to redirect 'spinland.org,' 'www.spinland.org,' 'spinland.net,' and 'www.spinland.net.' My understanding of how the syntax works is weak enough that I'm in over my head. Could you tell me how to get all of that busy stuff worked in? Many thanks in advance. ON EDIT: I just realized the typo in the title. Should have been 301, not 310. D'oh! Edited April 15, 2009 by TCH-Thomas Quote
OJB Posted April 15, 2009 Posted April 15, 2009 (edited) >RewriteRule ^spinland.(.*)$ http://www.spinland.$1 [R=301,L] Not sure if that would work??? I am no modrewrite expert by any means. I am actually interested in finding out the answer to this because I want to learn more about apache modrewrite.. I have a feeling a RewriteCond would be required Edited April 15, 2009 by OJB Quote
Spinland Posted April 15, 2009 Author Posted April 15, 2009 Well, based on forum searches this would be the code to handle the "www." issue: >Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^spinland.biz [nc] rewriterule ^(.*)$ [url="http://www.spinland.biz/$1"]http://www.spinland.biz/$1[/url] [r=301,nc] And this would be the code to handle redirecting the .org and .net addresses: >RewriteCond %{HTTP_HOST} !^www\.spinland\.biz$ [NC] RewriteRule ^(.*)$ [url="http://www.spinland.biz/$1"]http://www.spinland.biz/$1[/url] [R=301,L] Where I'm lost (assuming I even got the above correct) is how do you combine those, or can you just put both sets in the .htaccess file? Quote
Spinland Posted April 15, 2009 Author Posted April 15, 2009 Okay, I just realized there's a cpanel utility for this. I think I did it correctly, could a guru verify this is what I want? >RewriteEngine on RewriteCond %{HTTP_HOST} ^spinland.net$ [OR] RewriteCond %{HTTP_HOST} ^www.spinland.net$ RewriteRule ^.*$ "http\:\/\/www\.spinland\.biz" [R=301,L] RewriteCond %{HTTP_HOST} ^spinland.org$ [OR] RewriteCond %{HTTP_HOST} ^www.spinland.org$ RewriteRule ^.*$ "http\:\/\/www\.spinland\.biz" [R=301,L] RewriteCond %{HTTP_HOST} ^spinland.biz$ [OR] RewriteCond %{HTTP_HOST} ^www.spinland.biz$ RewriteRule ^.*$ "http\:\/\/www\.spinland\.biz" [R=301,L] Quote
Spinland Posted April 15, 2009 Author Posted April 15, 2009 Nope, got it wrong. That goes into an infinite loop because it tries to redirect www.spinland.biz, which everything else is being redirected to. This version seems to work: >RewriteEngine on RewriteCond %{HTTP_HOST} ^spinland.net$ [OR] RewriteCond %{HTTP_HOST} ^www.spinland.net$ RewriteRule ^.*$ "http\:\/\/www\.spinland\.biz" [R=301,L] RewriteCond %{HTTP_HOST} ^spinland.org$ [OR] RewriteCond %{HTTP_HOST} ^www.spinland.org$ RewriteRule ^.*$ "http\:\/\/www\.spinland\.biz" [R=301,L] RewriteCond %{HTTP_HOST} ^spinland.biz$ RewriteRule ^.*$ "http\:\/\/www\.spinland\.biz" [R=301,L] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.