0

以下の.htaccessの例では、誰かが次のようなURLを入力した場合...

http://mysite.com/ricks-motorcycles

...「ricks-motorcycles」と呼ばれるpublic_htmlの下のx.comのサブディレクトリからページを自動的にロードします。この手法はプロキシスループットと呼ばれます。

RewriteEngine On
RewriteRule ^ricks-motorcycles/(.*)$  http://x.com/ricks-motorcycles/$1 [P,L]

これは素晴らしいことですが、他の2つの状況をどのように処理しますか。

(1)httpではなくhttpsが必要な人。

(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 に答える