RewriteCond %{HTTP_HOST} !^www\.DOMAIN\.com
RewriteCond %{HTTP_HOST} ^(.*)\.DOMAIN\.com
RewriteRule ^(.*)$ http://DOMAIN.com/FolderName/$1 [L]
當一個重寫規則指向一個域,將出現一個明確的重定向。默認情況下是302重定向(臨時重定向)。
我建議你使用P
(代理)標誌。爲此,mod_proxy
應該啓用。
RewriteCond %{HTTP_HOST} !^www\.DOMAIN\.com
RewriteRule ^(.*)$ http://DOMAIN.com/FolderName$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(.*)\.DOMAIN\.com
RewriteRule ^(.*)$ http://DOMAIN.com/FolderName/$1 [L,P]
還記得設置ProxyReverse
指令。
Context: server config, virtual host, directory
所以,你不能在一個.htaccess
ProxyReverse
。
直接從:Proxying Content with mod_rewrite Apache Docs。
考慮使用ProxyPass或ProxyPassMatch儘可能優先於mod_rewrite。
訪問本作如何的ProxyPass:https://stackoverflow.com/a/9189447/858515
您:(1)需要一幀/ IFRAME; OR(2)在重寫和mod_proxy中需要[P]標誌 – 2012-02-14 06:57:16
@ J-16SDiZ mod_proxy在 – X10nD 2012-02-14 07:07:32