htaccess redirect subdomain AND subdirectory to external url

577 views Asked by At

I want redirect:

http://cbpq.luisgustavoventura.com/ AND http://luisgustavoventura.com/cbpq/

to:

http://cbpq.org.br/

i tried:

RewriteCond %{HTTP_HOST} ^(cbpq\.luisgustavoventura\.com|luisgustavoventura\.com/cbpq)$ [NC]
RewriteRule ^(.*) https://www.cbpq.org.br/$1 [L,R]

but doesn't work.

Please, suggest.

1

There are 1 answers

0
anubhava On BEST ANSWER

You cannot match /cbpq using %{HTTP_HOST} variable. It is better to keep these as 2 separate rules:

RewriteCond %{HTTP_HOST} ^luisgustavoventura\.com$ [NC]
RewriteRule ^cbpq(/.*)?$ http://www.cbpq.org.br$1 [L,NC,R=302]

RewriteCond %{HTTP_HOST} ^cbpq\.luisgustavoventura\.com$ [NC]
RewriteRule ^(.*)$ http://www.cbpq.org.br/$1 [L,NC,R=302]