Log in

View Full Version : .htaccess Redirect



tomyknoker
04-28-2008, 12:43 PM
Hi all... I know how to do a redirect to a new URL using a .htaccess file if I am pointing to a different server, however both domain.com and domain.com.cn are pointing to the same server, I just am wondering what I would add into my .htaccess file to get it to redirect from domain.com.cn to domain.com?

I have tried this:

Redirect permanent / http://domain.com

Which works for the .com.cn, but once it reidrects to the .com it keeps redirecting and the browser freaks out and gives me the following:


Too many redirects occurred trying to open “http://www.domain.com/”. This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.

Nile
04-28-2008, 01:57 PM
Well, do you have a redirect on domain.com?

tomyknoker
04-29-2008, 12:35 AM
They are on the same server so I am re-directing to .com and it keeps looping and looping

thetestingsite
04-29-2008, 12:42 AM
It shouldn't matter if they are on the same server, just as long as they are set up as separate virtual hosts. If that is not the case (the separate Virtual Hosts that is), then you could use PHP (or any other supported server side language) and have something like the following in your index page (or all the pages if you want):



<?php
if (strstr($_SERVER['HTTP_HOST'], 'domain.com.cn')) {
header('Location: http://www.domain.com');
}
?>

Not sure if you could do something equivalent using htaccess.

Hope this helps.

tomyknoker
04-29-2008, 12:48 AM
I want to use a .htaccess file if possible... I tried this and it kills both addresses:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^independentlycertifieddiamonds.com.au/ [NC]
RewriteRule ^(.*)$ http://www.independentlycertifieddiamonds.com/$1 [L,R=301]

I then tried this:


Redirect/ http://www.domain.com

This works for when the user types in .com.cn, but if they type in the .com it just keeps redirecting over and over to the same url and the server timesout