我认为这是相当简单的,但它似乎不适合我。我输入httpd.conf:
RewriteCond %{HTTP_HOST} ^blog.domain.com [NC]
RewriteRule ^(.+)$ http://www.domain.com/blog/index.php [L,R=301]
我在这里看了另外两个问题,一个建议使用ProxyPass,这似乎也不起作用。
我的另一个想法是为blog.domain.com提供虚拟主机。最好的方法是什么?
在我的。htaccess中,我这样使用它:
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]
请注意,我用(^|.)
来表示写www.blog.domain.com
的人!
别忘了处理https