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? Quote 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. Quote 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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.