Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache RewriteCond (subdomain)

I am trying to redirect request for a subdomain to main domain. ie: xxx.domain.com/blah/xyz --> domain.com/blah/xyz

My rewriteconds work fine for xxx.domain.com but for anything like xxx.domain.com/123/xyz 400 Bad Request is all I get…

Any help will be appreciated.

like image 547
Michał Miszczyszyn Avatar asked May 31 '26 22:05

Michał Miszczyszyn


1 Answers

Rule should look like :

RewriteCond %{HTTP_HOST} ^xxx.domain.com
RewriteRule (.*) http://domain.com/$1 [L]
like image 127
M'vy Avatar answered Jun 03 '26 22:06

M'vy