Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


1917 posts

Uber Geek
+1 received by user: 110


Topic # 84909 10-Jun-2011 13:36

Hello there.

I am having an issue with our domain setup. Thanks to the wisdom of the manager; we have a website on a shared hosting plan with openhost that was not intended to be the production url. I do not wish to re-setup the entire WP site and structure on another hosting plan so I have setup a domain alias.

Sounds great but I wish to avoid the content duplication issue. So in the .htacess file I am redirecting the old domain to the new domain using;  

RewriteCond %{HTTP_HOST} ^old.co.nz
RewriteRule (.*) http://www.new.co.nz/$1 [R=301,L]

This works for the homepage, but it does not redirect for pages down the tree.
How can I redirect any url associated from the old domain to the new alias domain?


Thanks for any help :o) 
 

Create new topic
2356 posts

Uber Geek
+1 received by user: 374

Trusted

  Reply # 479718 10-Jun-2011 13:48
Send private message

RewriteCond %{HTTP_HOST} ^old.co.nz$ [NC]
RewriteRule ^(.*)$ http://new.co.nz/$1 [L,R=301]


Updated (twice) to be a little better..






Professional yak shaver
1599 posts

Uber Geek
+1 received by user: 8

Trusted
BitSignal
Lifetime subscriber

  Reply # 479719 10-Jun-2011 13:49
Send private message

Try this:

RewriteRule ^/(.*) http://www.new.co.nz/$1 [L,R]

EDIT: LennonNZ beat me to the punch. Smile 




"Roads? Where we're going, we don't need roads." - Doc Emmet Brown



1917 posts

Uber Geek
+1 received by user: 110


  Reply # 479734 10-Jun-2011 14:44

Thanks for the help... I tried that but it does not seem to work. I am unsure if this is because we have a wordpress rewrite in there as well. It redirects the homepage perfectly though.


This is the htaccess file;



<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


RewriteCond %{HTTP_HOST} ^iluvnewzealand.co.nz$ [NC]
RewriteRule ^(.*)$ http://iluvnz.co.nz/$1 [L,R]
</IfModule>



An example of the non-redirection is here : http://iluvnewzealand.co.nz/kiwi-o-meter

Professional yak shaver
1599 posts

Uber Geek
+1 received by user: 8

Trusted
BitSignal
Lifetime subscriber

  Reply # 479736 10-Jun-2011 14:46
Send private message

I think that second RewriteRule is conflicting with the last one. Not sure how I would change that, though.




"Roads? Where we're going, we don't need roads." - Doc Emmet Brown

2356 posts

Uber Geek
+1 received by user: 374

Trusted

  Reply # 479738 10-Jun-2011 14:47
Send private message

RewriteCond %{HTTP_HOST} ^iluvnewzealand.co.nz$ [NC]
RewriteRule ^(.*)$ http://iluvnz.co.nz/$1 [L,R=301]


14395 posts

Uber Geek
+1 received by user: 1879


  Reply # 479750 10-Jun-2011 15:16
Send private message

SteveON: Hello there.

I am having an issue with our domain setup. Thanks to the wisdom of the manager; we have a website on a shared hosting plan with openhost that was not intended to be the production url. I do not wish to re-setup the entire WP site and structure on another hosting plan so I have setup a domain alias.

Sounds great but I wish to avoid the content duplication issue. So in the .htacess file I am redirecting the old domain to the new domain using;  

RewriteCond %{HTTP_HOST} ^old.co.nz
RewriteRule (.*) http://www.new.co.nz/$1 [R=301,L]

This works for the homepage, but it does not redirect for pages down the tree.
How can I redirect any url associated from the old domain to the new alias domain?


Thanks for any help :o) 

 


 

Wouldn't you be best to contact the host, as they would know the settings for their server.



1917 posts

Uber Geek
+1 received by user: 110


  Reply # 479754 10-Jun-2011 15:30

Humm, looks like the rewrite does not work. I will just have to get a server setup for separate domains.

2356 posts

Uber Geek
+1 received by user: 374

Trusted

  Reply # 479760 10-Jun-2011 15:42
Send private message

See This.. http://stackoverflow.com/questions/4550829/htaccess-apache-url-rewrite-for-wordpress-permanently-poi...

You have to swap the order around...



RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^iluvnewzealand.co.nz$ [NC]
RewriteRule ^(.*)$ http://iluvnz.co.nz/$1 [L,R]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


Create new topic

Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.