Jump to content

Redirection using mod rewrite in the .htaccess file?


extrovertive

Recommended Posts

Ok, I have two domains.

 

Let's say I want http://XXX.domainA.com to go to http://domainB.com/title-goes-here

 

How can I do that using mod_rewrite in the .htacess file for my domainA.com domain? Like, http://funny.domainA.com would then redirect to http://domainB.com/blog/the-title-of-something

 

I know I can create a subdomain on domainA and have a 301 redirect to go to another URL.

 

But I'm wondering if I can just use mod-rewrite for my domainA.com?

It's difficult to understand exactly what your trying to achieve as you have given very generalised statement and no specific example. You say http://funny.domainA.com would redirect to http://domainB.com/blog/the-title-of-something, but there is no correlation between the two URLs. For that reason a Redirect directive makes far more sense than using mod_rewrite. If you'd have said you wanted http://funny.domainA.com to redirect to http://domainB.com/blog/funny then I could understand using a RewriteRule.

Assuming http://funny.domainA.com/ actually arrives at the right place (not all servers have sub-domains enabled in that way), something like this should work...

 

RewriteCond {HTTP_HOST} !^www.domainA.com$ 
RewriteCond {HTTP_HOST} ^([a-zA-Z]+).domainA.com$
RewriteRule ^.*$ http://domainB.com/blog/%1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.