htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Multple domains using htaccess
PostPosted: 28 Oct 2006 07:45 
Offline

Joined: 28 Oct 2006 07:37
Posts: 44
Hi,

I know this can be done in http.conf but is it possible to use .htaccess & Mod_rewrite to map domain names to a directory so that you can run multiple independant sites from the same hosting account?

Is the following code along the right lines?

Code:
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) /sites/example.com/htdocs/$1 [L]


Top
 Profile  
 
 Post subject:
PostPosted: 30 Oct 2006 07:57 
Offline

Joined: 28 Oct 2006 07:37
Posts: 44
Just realised this still doesn't work quite properly but can't figure out why.

If I try going to

http://www.primary-site.co.uk/foo/index.html it works perfectly

However, if I go to http://www.primary-site.co.uk/foo/

It presents a 302 redirect to http://www.secondary-site.co.uk/foo/index.html

Can anyone point me in the right direction to find out why? Any help greatly appreciated!

Present Code:
Code:
RewriteCond %{HTTP_HOST} ^primary-site\.co\.uk [NC]
RewriteRule (.*) http://www.primary-site.co.uk/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^secondry-site\.co\.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?additional-url\.co\.uk [NC]
RewriteRule (.*) http://www.secondary-site.co.uk/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.secondary-site\.co\.uk [NC]
RewriteCond %{REQUEST_URI}!^/websites/
RewriteRule (.*) /websites/$1 [L]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Adsense [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB