PDA

View Full Version : redirect .com to .org


BPartch
04-08-2008, 08:00 AM
How can I redirect all urls from domain.com to domain.org?

SarahG
04-08-2008, 12:22 PM
what's the set up like? Is one parked on the other?

If you've got one on one server and one elsewhere then try

Redirect 301 / http://www.domain.org/

If they're both parked on the same site and you only want domain.org to work then use

RewriteCond %{HTTP_HOST} !^.*\.domain\.org
RewriteRule (.*) http://www.domain.org/$1 [R=301,L]

Or omit the www. in the third line if you want just http:// domain.org/

To specifically redirect just domain.com to domain.org (eg. domain.net wouldn't redirect) then use

RewriteCond %{HTTP_HOST} ^.*\.domain\.com
RewriteRule (.*) http://www.domain.org/$1 [R=301,L]

Of course, all the rewrites need "RewriteEngine On" somewhere above them for them to work.

davemcnally
04-08-2008, 01:07 PM
I couldn't really understand Sarah's advice (I'm not that smart!) so I just hope this isn't the same way.

You could either use a URL Redirect service depending on where you register your domains and what they offer. Or, if you have cPanel with your hosting and wish to keep the .com hosted, you could always use the option for Redirects within cPanel.

SarahG
04-08-2008, 02:00 PM
Mine goes in htaccess, guess I should have mentioned that for anyone else reading (I know Ben understands that already).

The redirects in cPanel can create similar code to the first option but it's not as flexible as editing the htaccess directly.

BPartch
04-08-2008, 03:50 PM
Hello

Thanks Sarah, Yes I want the .htaccess version. I bought a new domain that is the .org version and I am going to move the .com version to it, thus I want to redirect the old .com URLs to the .org ones.

Thanks all. :)

BPartch
04-08-2008, 04:07 PM
Okay this is what I have in .htaccess already:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.org$ [NC]
RewriteRule ^(.*)$ http://domian.org/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]The top part forces no www then the rest is default WP. How do I add your deal above to it Sarah? :)

this part: RewriteCond %{HTTP_HOST} ^.*\.domain\.com
RewriteRule (.*) http://www.domain.org/$1 [R=301,L]

Also I want the .com domain to still work, (not the old urls but a new site alltogether) if that makes any difference.

Thanks

SarahG
04-08-2008, 05:21 PM
You could add

RewriteCond %{HTTP_HOST} ^.*\.domain\.com [NC,OR]

above the second line.

However if you want the .com to still work then you're going to have to manually list each filename, unless you've got a specific pattern, eg all the old files are in a particular directory. So the above code will work for all URLs under the .com, which isn't what you want.

Most likely you'll need to do a manual list of pages so

RewriteCond %{HTTP_HOST} ^.*\.domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/path/to/file/$ [NC]
RewriteRule (.*) http://domain.org/$1 [R=301,L]

And you'll potentially have to do that for every old file as you need to say 'if the host domain is domain.com and they've chosen this particular file, then redirect to the same path on domain.org. As mentioned, if there's a particular pattern or way of identifying the files through a regex then we could reduce the work but I'd need to see a list of URLs or paths on the domain.