Jump to content

Recommended Posts

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]

"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.

"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]

:thumb-up:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.