Reputation: 457
On my Drupal site the provided .htaccess file allows me to redirect www.example.com requests to example.com using this code:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
In addition to this, I would also like to point all subdomain requests to example.com as well. For example:
So, how would I modify the above code to accomplish this?
Upvotes: 1
Views: 364
Reputation: 785491
You can have another rule after your current rule:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^[^.]+\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]
Upvotes: 1