
次の仮想ホスト ファイルがあります:
<IfModule !wsgi_module>
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix run/wsgi
</IfModule>
<VirtualHost *:80>
RewriteEngine On
RewriteLog "/var/log/httpd/rewrite_log"
RewriteLogLevel 1
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
</VirtualHost>
<VirtualHost *:443>
ServerName https://tendril-api.dev.adnxs.net
ServerAlias 06.tendril-api.dev.nym2.adnexus.net/api
RewriteEngine on
RewriteRule ^docs$ docs/ [R]
...
# SSL & WSGI Setup
</VirtualHost>
何らかの理由で、docs
書き換えルールがまったく効きません。これはなぜでしょうか? *:80 VirtualHost の HTTP-->HTTPS 書き換えルールは正常に動作しています。私も似たようなことをしています。
これは、異なる VirtualHost に 2 つの異なる Rewrite ルールがあることに関係しているのでしょうか?
何か案は?
答え1
に従ってhttp://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule:-
何が一致しますか?
VirtualHost コンテキストでは、パターンは最初にホスト名とポートの後、クエリ文字列の前の URL の部分 (例: "/app1/index.html") と照合されます。
パターンは「docs」の正確な URL と一致しています。実際の URL はおそらく「/docs」なので、「^」の後に「/」を追加すると機能する可能性があります:-
RewriteRule ^/docs$ docs/ [R]