extrovertive Posted February 18, 2010 Share Posted February 18, 2010 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? Link to comment https://forums.phpfreaks.com/topic/192486-redirection-using-mod-rewrite-in-the-htaccess-file/ Share on other sites More sharing options...
cags Posted February 18, 2010 Share Posted February 18, 2010 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. Link to comment https://forums.phpfreaks.com/topic/192486-redirection-using-mod-rewrite-in-the-htaccess-file/#findComment-1014256 Share on other sites More sharing options...
extrovertive Posted February 18, 2010 Author Share Posted February 18, 2010 Yes, that would work. http://funny.domainA.com/ would redirect to http://domainB.com/blog/funny Can anyone help? Link to comment https://forums.phpfreaks.com/topic/192486-redirection-using-mod-rewrite-in-the-htaccess-file/#findComment-1014456 Share on other sites More sharing options...
cags Posted February 18, 2010 Share Posted February 18, 2010 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 Link to comment https://forums.phpfreaks.com/topic/192486-redirection-using-mod-rewrite-in-the-htaccess-file/#findComment-1014463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.