Forum Moderators: phranque
What I really want is have www.mysite.com/blog to redirect to my subdomain blog.mysite.com. IT WORKS!
BUT, www.mysite.com/BLOG or if the cases do not match exactly to 'blog', then it'll be 404. Why is that?
I tried replacing [L,R=301] to [NC] or [L,R=301,NC] and stuff, no luck.. Any help would be fabulous, thanks in advance.
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ [mysite.com...] [L,R=301]
RedirectMatch 301 ^/blog/(.*)$ [blog.mysite.com...]
The order the rules are processed is indeterminate, as rules are processed in 'per module' order, not in the order they appear on the page.
That is, all rules from Mod_Alias might be processed before all those from Mod_Rewrite - or maybe it is the other way round.
Stick with RewriteRule for all of your rules to avoid that problem, and order the rules from most specific to least specific.
That said, Merry Christmas! :
RewriteRule ^blog/(.*)$ http://blog.example.com/$1 [NC,R=301,L]
#
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://blog.example.com/$1 [R=301,L]
Note that the redirect target for the second rule has been changed in order to avoid multiple 'chained' redirects when "example.com" is requested.
Jim