Forum Moderators: phranque
I have pointed them all to the same hosting account and they all have their own folder within i this..
I have tried with htaccess to push which ever domain name you put view the folder so domain2.com would goto domain.com/domain2 and have the URL keep as domain2.com
I couldn't get that to work, so i used PHP to do that, but now coz of that all the files etc.. are not beng found, a long winded approach would be to do this..
# DEFAULT SHARES
RewriteRule ^scripts/(.*)$ /shared/scripts/$1 [L]
RewriteRule ^images/general2/invis.gif /shared/images/general2/invis.gif [L]
RewriteRule ^images/towns/townslarge/(.*)$ /shared/images/towns/townslarge/$1 [L]
RewriteRule ^images/events/eventssmall/(.*)$ /shared/images/events/eventssmall/$1 [L]
RewriteRule ^images/prices/(.*)$ /shared/images/prices/$1 [L]
RewriteRule ^images/buttons/moreinfo/(.*)$ /shared/images/buttons/moreinfo/$1 [L]
RewriteRule ^images/buttons/buyit/(.*)$ /shared/images/buttons/buyit/$1 [L]
RewriteRule ^form/(.*)$ /shared/form/$1 [L]
# DOMAINS
RewriteRule ^css/(.*)$ /domain2/css/$1 [L]
RewriteRule ^images/general/(.*)$ /domain2/images/general/$1 [L]
RewriteRule ^images/buttons/(.*)$ /domain2/images/buttons/$1 [L]
RewriteRule ^contact.htm /domain2/contact.htm [L]
RewriteRule ^booking.php /domain2/booking.php [L]
RewriteRule ^enquiry.php /domain2/enquiry.php [L]
RewriteRule ^thanks.htm /domain2/thanks.htm [L]
which of course with 80 odd domains would be tedious..
So i was wondering if there was a way i gould manipulate the actuall domain name (minus the www. and tld) to give me the folder to point the files to?
Any help would be gratefully appreciated..
Welcome to WebmasterWorld!
There is a method to rewrite any subdomain request to a unique subdirectory [webmasterworld.com] using mod_rewrite in .htaccess. Unfortunately, this method only works if your server supports POSIX 1003.2 regular expressions, which includes a new "atomic back-references" feature. This is supported on FreeBSD servers, and possibly a few others.
The main problem you have to deal with in .htaccess is preventing an "infinite loop" of rewriting. Because you're using mod_rewrite in a per-directory (.htaccess) context, the output of any rewriting done at the driectory level must be passed back through httpd.conf and again through any .htaccess files in the filepath of the newly-rewritten URL -- in order to check for access restrictions or to invoke further rewrites which apply to the new path. So the trick is to avoid having your rewrites invoked multiple times, which will cause a loop and usually lead to a 500-Server Error.
This can be done in several ways. The code cited above does it by checking to see if the current URL already contains the subdomain name. But it relies on an operating system feature not available in most servers.
Another way to do it is to insert a common exclusion element in the URL -- something that can be detected to avoid recursive rewriting, without having to explicitly test for each subdomain name. For example, rewrite:
www.blue.example.com/file --> /subd/blue/file
red.example.com/file ---------> /subd/red/file
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/subd/
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example\.com
RewriteRule (.*) /subd/%2/$1 [L]
RewriteRule ^contact\.htm /domain2/contact.htm [L]
RewriteRule ^booking\.php /domain2/booking.php [L]
RewriteRule ^enquiry\.php /domain2/enquiry.php [L]
RewriteRule ^thanks\.htm /domain2/thanks.htm [L]
RewriteRule ^(contact\.htm¦booking\.php¦enquiry\.php¦thanks\.htm)$ /domain2/$1 [L]
Change the broken pipe "¦" characters to a solid pipe characters before trying to use this. (Posting on this baord modifies that character).
Jim
Ie: it looks at the rewriteRules for domain 1 where i am looking at domain 3.
So i want to do a lil bit of code to say if the domain is this do this. i tried:
RewriteCond %{HTTP_HOST} ^http://(.+\.)?example\.co.uk [NC]
RewriteRule ^css/(.*)$ /example/css/$1 [L]
RewriteRule ^images/general/(.*)$ /example/images/general/$1 [L]
RewriteRule ^images/buttons/(.*)$ /example/images/buttons/$1 [L]
RewriteRule ^(contact\.htm¦booking\.php¦enquiry\.php¦thanks\.htm)$ /example/$1 [L]
but doesn't wanna work.. Any help would be appreciated.
[edited by: jdMorgan at 4:54 pm (utc) on Mar. 17, 2005]
[edit reason] Removed specifics per TOS. [/edit]