Do not redirect subdomain in htaccess

I wrote redirect rules for my primary domain:

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

But then I try to access one of my subdomains: http://lojinha.projetomedicina.com.br redirects it to / portal.

How can I change my .htaccess to not allow forwarding from my subdomain?

+4
source share
1 answer

RedirectMatchis a directive from mod_alias. You need RewriteRulehere:

RewriteEngine on

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

Before testing this change, be sure to clear your browser cache.

+2
source

Source: https://habr.com/ru/post/1615704/


All Articles