簡體   English   中英

不要在htaccess中重定向子域

[英]Do not redirect subdomain in htaccess

我為我的主域寫了這個重定向規則:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^projetomedicina\.com\.br$ [OR]
RewriteCond %{HTTP_HOST} ^www\.projetomedicina\.com\.br$
RewriteCond %{REQUEST_URI} ^/site[/]?$
RewriteCond %{HTTP_HOST} !^(lojinha_\.projetomedicina\.com\.br$ [NC]
RedirectMatch 301 ^/$ /portal
RedirectMatch 301 ^/site/$ http://projetomedicina.com.br/portal

但后來我嘗試訪問我的一個子域: http//lojinha.projetomedicina.com.br它重定向到/ portal。

如何修改我的.htaccess以便不允許從我的子域重定向?

RedirectMatchmod_alias指令。 你需要的是RewriteRule

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?projetomedicina\.com\.br$ [NC]
RewriteRule ^(site)?/?$ /portal [L,R=302,NC]

在測試此更改之前,請務必清除瀏覽器緩存。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM