Forum Moderators: phranque
We have an account with about 200 addon domains. Each addon domain has its own folder but it is accessed directly like [domain1.com...]
So the directory is something like this:
MainDomain
¦
¦-Domain1
¦ ¦-index.php
¦ ¦-somefile.php
¦-Domain2
¦ ¦-index.php
¦ ¦-somefile.php
¦-index.php
¦-client_display.php
Now, what we want is that our user can enter [domain1.com...] and this request be handled by "client_display.php?client=clientName" (client_display.php is located in the root of the "maindomain") while the address bar still displays [domain1.com...]
This should be the case with all addon domains.
I don't know if its clear what I am asking
I hope some mod_rewrite expert can help
Thanks!
I think the following will do the trick:
# This conditional should take what is in between the first and second slashes in the REQUEST_URI. Parantheses means that it will become a variable named %1
RewriteCond %{REQUEST_URI} /([^/]+)/?.* [NC]
# This rule will use the variable from above.
RewriteRule .* /client_display.php?client=%1 [L] I haven't tested it though, but it's worth a try?
Be aware that this should rewrite any request to subcatalogs under root. If you don't want that to happen, you need extra conditionals, or you could rewrite requests to for instance domain.com/clients/clientName only.
If you still want domain.com/clientName, you must add conditionals like;
RewriteCond %{REQUEST_URI} !^/images [NC]
RewriteCond %{REQUEST_URI} !^/someCatalog [L] Or you could just place clients under a catalog such as /clients/clientName.
That would make the rule:
RewriteCond %{REQUEST_URI} /clients/([^/]+)/?.* [NC]
RewriteRule .* /client_display.php?client=%1 [L] Disclaimer: I am still a mod_rewrite newbie, and can't guarantee that this will work :)
-Eivind
[edit: missing flags]
[edited by: valder at 4:46 pm (utc) on Jan. 10, 2005]
It works when it is used with the "MainDomain", but when I use it with the addon domain (e.g [addonDomain.com...] ) I get an Internal server error.
Perhaps this code works:
RewriteCond %{REQUEST_URI} !/client_display\.php.* [NC]
RewriteCond %{REQUEST_URI} /([^/]+)/?.* [NC]
RewriteRule ^.* /path/to/document_root/client_display\.php\?client=%1 [L] Hope it helped,
-Eivind