Forum Moderators: phranque
So recently I was able to create a htaccess rewrite with the subdomain as my variable as follows:
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com
RewriteRule .* http://example.com/index.php?affname=%1 [L,R]
This is working great! (I did need to create a wildcard A Record in my DNS entries pointing back to my IP).
Now I also want to be able to add variables beyond the root and pass it, but I can't figure this out. For example:
http://Joe.example.com/Jane
would redirect to:
http://example.com/index.php?affname=Joe&var2=Jane
Can I do this? (If so, HOW?)
cheers...matt
[edited by: jdMorgan at 4:49 pm (utc) on Oct. 1, 2009]
[edit reason] example.com [/edit]
RewriteCond $1 !^index\.php$
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule ^(.*)$ /index.php?affname=%1&path=$1 [L]
Jim
A third, optional step would be to now redirect any direct client requests for "index.php?affname=xyz&path=/whatever" back to the canonical URL, "affname.example.com/whatever" in order to avoid duplicate content problems (the same content served in response to two or more URLs).
Jim