开发者

URL rewrite blog.domain.com to www.domain.com/blog

开发者 https://www.devze.com 2023-03-26 20:14 出处:网络
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]

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消