Reputation: 17561
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.mydomain.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?
Upvotes: 0
Views: 474
Reputation: 3861
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]
Upvotes: 0