问题描述
在下面的.htaccess例如,如果有人类型类似如下的URL ......
In the .htaccess example below, if someone types in a URL like the following...
http://mysite.com/ricks-motorcycles
...它会自动从x.com的子目录页面public_html下称里克斯 - 摩托车。这种技术被称为的代理吞吐的。
...it will automatically load the page from x.com's subdirectory under public_html called "ricks-motorcycles". This technique is called Proxy Throughput.
RewriteEngine On
RewriteRule ^ricks-motorcycles/(.*)$ http://x.com/ricks-motorcycles/$1 [P,L]
这是伟大的,但我怎么处理其他两种情况:
This is great, but how do I handle two other situations:
(1)有人想HTTPS代替HTTP。
(1) Someone wanting https instead of http.
(2)有人想...
HTTP#// ricks-motorcycles.mysite.com /
http#//ricks-motorcycles.mysite.com/
...
HTTP#// mysite.com/ricks-motorcycles /
http#//mysite.com/ricks-motorcycles/
(开关#有:以上是因为计算器是可以发布挡住我)
(Switch # with : above because StackOverflow was blocking me from posting.)
推荐答案
您可以限定你重写了的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的文档。
For more information, see the mod_rewrite documentation.
这篇关于处理子域和https使用的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!