在下面的.htaccess示例中,如果有人输入如下所示的网址...
http://mysite.com/ricks-motorcycles
...它会自动从名为“ricks-motorcycles”的public_html下的x.com子目录中加载页面。此技术称为代理吞吐量。
RewriteEngine On
RewriteRule ^ricks-motorcycles/(.*)$ http://x.com/ricks-motorcycles/$1 [P,L]
这很棒,但我该如何处理其他两种情况:
(1)有人想要https而不是http。
(2)有人想......
的http //#ricks-motorcycles.mysite.com /
......而不是......
的http //#mysite.com/ricks-motorcycles /
(切换#with:上面因为StackOverflow阻止我发布。)
答案 0 :(得分:1)
您可以使用RewriteCond
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^ricks-motorcycles/(.*)$ https://example.com/ricks-motorcycles/$1 [P,L]
RewriteCond %{HTTP_HOST} =ricks-motorcycles.mysite.com
RewriteRule ^(.*)$ http://example.com/ricks-motorcycles/$1 [P,L]
有关详细信息,请参阅mod_rewrite documentation。