.htaccess Redirect from subdomain to domain
I've tried a bunch of examples here on SO and modifed them, but none are exactly what I need and as a result either fail with 500 server errors (meaning the rewrite rules are wrong) or redirect just the subdomain to the domain and not any of the full URLs of pages.
I need to redirect all URLs under blog.mydomain.com to www.mydomain.com/blog, i.e. redirect blog.mydom开发者_如何学编程ain.com/page1 to www.mydomain.com/blog/page1
This
RedirectMatch 301 ^/ http://mydomain.com/blog/
redirects all URLs of blog.mydomain.com to the root of mydomain.com/blog/, not the full URL. Any ideas?
RedirectMatch permanent (.*) http://mydomain.com/blog/$1
I use this to redirect one domain to another, but should work fine for subdomains/subdirectories:
RewriteCond %{HTTP_HOST} ^blog\.mysite\.com$ [NC]
RewriteRule ^ http://mysite.com/blog%{REQUEST_URI} [R=301,L]
精彩评论