bull Posted February 1, 2017 Share Posted February 1, 2017 Hi all, i' ve got two domains on a single shared hosting so trying to get to separate websites to work on it with help of htaccess. So far I have managed to get it to work that http://example.com and http://example2.com both redirects fine, but noticed if i start the url with http://www.. it doesnt work. Just started to mess about with htaccess business so cant get my head around it at all, if anyone could help out. Thank you! contents of the htaccess file: RewriteEngine on Options +FollowSymLinks RewriteBase / # Site 1 RewriteCond %{HTTP_HOST} ^test247.info$ [NC] RewriteCond %{REQUEST_URI} !^/_test247_info/.*$ RewriteRule ^(.*)$ /_test247_info/$1 [L] # Site 2 RewriteCond %{HTTP_HOST} ^test247.com$ [NC] RewriteCond %{REQUEST_URI} !^/_test247_com/.*$ RewriteRule ^(.*)$ /_test247_com/$1 [L] Quote Link to comment Share on other sites More sharing options...
requinix Posted February 2, 2017 Share Posted February 2, 2017 "It doesn't work" is meaningless. How does it not work? Assuming you have DNS set up correctly, RewriteCond %{HTTP_HOST} ^test247.info$ [NC]that will only accept "test247.info" as a domain name. Not "www.test247.info". Modify it to allow for an optional "www.", or add a second RewriteCond with an [OR] to match that name. Quote Link to comment Share on other sites More sharing options...
bull Posted February 6, 2017 Author Share Posted February 6, 2017 "It doesn't work" is meaningless. How does it not work? Assuming you have DNS set up correctly, RewriteCond %{HTTP_HOST} ^test247.info$ [NC]that will only accept "test247.info" as a domain name. Not "www.test247.info". Modify it to allow for an optional "www.", or add a second RewriteCond with an [OR] to match that name. the condition wasnt met and i didnt know how to update it so that it would redirect both with and without www. at the start of the address. after a few unlucky attempts i finally found a solution which was RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] Quote Link to comment 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.