Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After trying several solutions I just can't seem to get this to work.

I owned a .org and had urls like

http://mydomain.org/view/3242343
http://mydomain.org/login
http://mydomain.org/page/5

and I now have the .com and want all of them to be taken right to their .com equivalents:

http://mydomain.com/view/3242343
http://mydomain.com/login
http://mydomain.com/page/5

etc.

The rules I've tried so far seem to take any URL from .org and just send them to the root of mydomain.com.

What htaccess rule do I need?

Thanks,

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Assuming it's an .htaccess in the DocumentRoot of the .org site (and not the .com site, which would need a RewriteCond to prevent a redirect loop):

RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301]
share|improve this answer
    
This doesn't work - redirects mydomain.org/view/9 to mydomain.com. htaccess is in the documentRoot of the .org –  barfoon Sep 28 '11 at 19:45
3  
@barfoon In fact it does not. The $1 contains the information captured in the match; in this case, everything except the root / due to the context of the .htaccess. You likely have some config still in place somewhere in your Apache configuration from another attempt. Change it to something like RewriteRule ^(.*)$ http://mydomain.com/spleen/$1 [R=301] to verify that this config isn't the one doing the redirect. Check the <VirtualHost>? And make sure you've reloaded the service if you've made changes elsewhere than .htaccess. –  Shane Madden Sep 28 '11 at 19:49
    
I just tried this and that is the result I got. I have not touched the <VirtualHost> on either domain since obtaining both. I even removed all rules on the .com htaccess to see if there was a conflicting rule. No change. –  barfoon Sep 28 '11 at 19:51
    
@barfoon Umm.. what result is it that you got? With what request URL? –  Shane Madden Sep 28 '11 at 19:54
    
I typed in mydomain.org/view/9 and I got sent to mydomain.com –  barfoon Sep 28 '11 at 19:56
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.