I thought this was pretty simple, but it doesn't seem to be working for me. I put in my httpd.conf:
RewriteCond %{HTTP_HOST} ^blog\.domain\.com [NC]
RewriteRule ^(.+)$ http://www.domain.com/blog/index.php [L,R=301]
I looked at two other questions here, one 开发者_运维问答recommended ProxyPass, which didn't seem to work either.
My other thought was a VirtualHost for blog.domain.com. What's the best way to do this?
In my .htaccess I use it like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} (^|.)blog\.domain\.com [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ http://www.domain.com/blog/$1 [L]
RewriteCond %{HTTP_HOST} (^|.)blog\.domain\.com [NC]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ https://www.domain.com/blog/$1 [L]
Note that I use (^|.)
for people who would write www.blog.domain.com
!
Dont forget to handle https also.
精彩评论