Hello all, I need help with setting up this mod_rewrite function on my server. I have already setup and got the wildcard dns working, but here is the rest of the equation... http://www.domain.com/viewall.php?cat=1 to http://subdomain1.domain.com/viewall.php ...and there would be more categories... http://www.domain.com/viewall.php?cat=2 to http://subdomain2.domain.com/viewall.php http://www.domain.com/viewall.php?cat=3 to http://subdomain3.domain.com/viewall.php Any ideas??? $10 via paypal to the first who can get this working for me... Thanks and good luck!
RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=(.*)$ [NC] RewriteRule ^(.*) http://subdomain$1.domain.com/viewall.php [R=301,L] Code (markup):
Thanks for the QUICK reply! Question though...OK, I am a complete n00b at mod_rewrite no matter how much I read about it....so how about I change it up a bit to make it exact to what I want... http://www.domain.com/viewall.php?cat=1 to http://ford.domain.com/viewall.php http://www.domain.com/viewall.php?cat=2 to http://chevy.domain.com/viewall.php http://www.domain.com/viewall.php?cat=3 to http://toyota.domain.com/viewall.php Sorry, but I got confused about the subdomain$1 thinking it was a variable...AHA7 - the question is locked for you for a while if you are able to give me the correct code -- my fault, I should have been more specific...
In this case you'll have to write a condition and a rewrite rule for each subdomain. How many subdomains do you have?
You can do this: http://www.domain.com/viewall.php?cat=subdomain to http://subdomain.domain.com/viewall.php http://www.domain.com/viewall.php?cat=hi to http://hi.domain.com/viewall.php With this code: RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=(.*)$ [NC] RewriteRule ^(.*) http://$1.domain.com/viewall.php [R=301,L] Code (markup):
There are 8 'virtual' subdomains that I would like to have...I kind of figured on the 8 different case statements...
I see how this would work... http://www.domain.com/viewall.php?cat=subdomain to http://subdomain.domain.com/viewall.php http://www.domain.com/viewall.php?cat=hi to http://hi.domain.com/viewall.php ...but what about if on the cat=x, x is a number instead of what I want the subdomain to be? http://www.domain.com/viewall.php?cat=1 to http://ford.domain.com/viewall.php ??
Did you see my very last post above? If you'd like I can give you the 8 statements if you give me the subdomains.
RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=1$ [NC] RewriteRule ^(.*) http://Ford.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=2$ [NC] RewriteRule ^(.*) http://GM.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=3$ [NC] RewriteRule ^(.*) http://Chrysler.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=4$ [NC] RewriteRule ^(.*) http://Toyota.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=5$ [NC] RewriteRule ^(.*) http://Honda.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=6$ [NC] RewriteRule ^(.*) http://Acura.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=7$ [NC] RewriteRule ^(.*) http://Nissan.domain.com/viewall.php [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\.com RewriteCond %{REQUEST_URI} ^/viewall.php?cat=8$ [NC] RewriteRule ^(.*) http://Chevy.domain.com/viewall.php [R=301,L] Code (markup): R=301 issues a 301 (moved permanently) response. If you don't want to 301 redirect those pages then replace all [R=301,L] with [L]
Lovely....I will implement and test them tonight. If they work, expect money in your paypall account. PM over your paypal email address. Thanks for the help!!!