Apache 將子網域重新導向到特定資料夾

Apache 將子網域重新導向到特定資料夾

我需要重定向所有流量

http://subdomain.domain.com/

http://subdomain.domain.com/folder/

當然,「資料夾」是一個特定的資料夾。我試過這個:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$
RewriteRule ^.*$ http://subdomain.domain.com/folder/ [L]

但這不起作用。怎麼了?

答案1

嘗試這個:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$
RewriteRule ^/$ http://subdomain.domain.com/folder/ [R,L]

我所做的唯一更改是R在 RewriteRule 之後新增選項。該選項告訴 Apache 進行 302 重定向。R=301如果您想要永久重新導向,則可以使用。

相關內容