0

在下面的 .htaccess 示例中,如果有人键入如下 URL...

http://mysite.com/ricks-motorcycles

...它将自动从 x.com 的 public_html 下名为“ricks-motorcycles”的子目录加载页面。这种技术称为代理吞吐量

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/

(在上面用 : 切换 # 因为 StackOverflow 阻止了我发帖。)

4

1 回答 1

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 文档

于 2009-06-28T08:28:14.463 回答