Currently I have a page residing at:
http://www.example.com/site/page
In my htaccess I have the current rule:
RewriteRule ^
Try this one :
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ [NC]
RewriteRule .* retailer.php?linklabel=%1 [L,QSA]
Try:
RewriteCond %{HTTP_HOST} !^www.[NC]
RewriteCond %{HTTP_HOST} ^(.+?)\.example.com$ [NC]
RewriteRule ^$ retailer.php?linklabel=%1 [L,QSA]
You can't match against the host in a RewriteRule
, so you'll need to do it against the %{HTTP_HOST}
var in a RewriteCond
, then use the %1
backreference to get that match.
This will currently only match against URI's that are exactly /
. So it won't match against http://page.example.com/something
unless you change the regular express at from ^$
to ^something$
.