Jump to content

Recommended Posts

Posted (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 by TCH-Thomas
Posted (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 by OJB
Posted

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?

Posted

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]

Posted

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]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...