Forum Moderators: phranque
RewriteRule ^category.example.com/article/(.*)$ www.example.com/category/$1/ [R=301]
...but it doesn't.
[edited by: jdMorgan at 2:43 am (utc) on Sep. 9, 2007]
[edit reason] example.com [/edit]
So in short, RewriteRule cannot see the domain name.
You must use a RewriteCond to examine the requested hostname (taken from the "Host:" header received from the client). Assuming that the code resides in example.com/.htaccess:
[code]
RewriteCond %{HTTP_HOST} ^category\.example\.com
RewriteRule ^article/(.+)/?$ http://www.example.com/category/$1/ [R=301,L]
[code]
Because you said you used to use multiple subdomains, you may want to redirect more of them using the same rule:
[code]
RewriteCond %{HTTP_HOST} ^(category)\.example\.com [OR]
RewriteCond %{HTTP_HOST} ^(category2)\.example\.com [OR]
RewriteCond %{HTTP_HOST} ^(classification)\.example\.com
RewriteRule ^article/(.+)/?$ http://www.example.com/%1/$1/ [R=301,L]
[code]
Note that the last RewriteCond must not have an [OR] flag on it, since the [OR] flag operates between the RewriteCond line that it is on and the following RewriteCond; Trying to [OR] a RewriteCond with a RewriteRule doesn't make sense anyway.
Jim