Forum Moderators: phranque
If another person type [example2.com,...] then it should be [example2.com?site_id=2...]
All those domains will be parked in my one main domain's subfolder.
I am trying to use htaccess and still don't get it right. That url parameter(site_id) should be come along with other urls in corresponding domains, for example, [example1.com...] .
Currently, this works for testing with one domain,
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.php$ /$1.php?site_id=1 [QSA,L,NE,R]
But when I go to other pages, I lost site_id parameter.
Please advise.
Thanks,
Kevin
[edited by: jatar_k at 4:13 pm (utc) on May 9, 2006]
[edit reason] swapped to example [/edit]
you'll need to rewrite all of the URLs within the page to have?site_id=blahblah on the end of them. You could certainly to it with php or another scripting language, but I'm not sure that apache will handle that for you.
Unless you can read the ( unreliable ) HTTP_REFERER on subsequent requests and get the query string out of that to reuse?
hth,
Andy
RewriteEngine On
RewriteCond %{QUERY_STRING} !site_id=.
RewriteCond %{HTTP_HOST} !^(www\.)?main_domain\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^:]+)
RewriteRule ^([\.]+\.php)$ /$1?site_id=%2 [QSA,L]
A simple example of an associative list in mod_rewrite might be:
RewriteEngine On
RewriteCond %{QUERY_STRING} !site_id=.
RewriteCond %{HTTP_HOST}<>2 ^(www\.)?domaintwo\.com[^<]+<>(2) [OR]
RewriteCond %{HTTP_HOST}<>3 ^(www\.)?domainthree\.com[^<]+<>(3) [OR]
RewriteCond %{HTTP_HOST}<>4 ^(www\.)?domainfour\.net[^<]+<>(4) [OR]
RewriteCond %{HTTP_HOST}<>5 ^(www\.)?domainred\.com[^<]+<>(5) [OR]
RewriteCond %{HTTP_HOST}<>6 ^(www\.)?domainblue\.com[^<]+<>(6)
RewriteRule ^([\.]+\.php)$ /$1?site_id=%2 [QSA,L]
Jim