Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.subdomain.example.com
RewriteRule (.*) http://subdomain.example.com/$1 [R=301,L]
Everything is working perfect for this subdomain but i want to write a rule that covers everybody on our site.
Can somebody please help?
Thank you
[edited by: jdMorgan at 1:57 pm (utc) on June 16, 2005]
[edit reason] Example.com [/edit]
Welcome to WebmasterWorld!
The key here is to create a back-reference to the subdomain pattern matched in your RewriteCond, and to include that back-reference in your RewriteRule substitution. This is almost exactly the same thing that you're doing with the filename back-referenced by "$1". The only difference is that back-references to RewriteConds use %1 through %9, rather that $1 through $9 as used for RewriteRule back-references:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com
RewriteRule (.*) http://%1.example.com/$1 [R=301,L]
See the documentation cited in our forum charter [webmasterworld.com] for more information.
Jim
[edited by: jdMorgan at 5:53 pm (utc) on June 16, 2005]