Reputation: 1840
My htaccess file has the following rules
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE]
I want to add condition for subdomains so subdomain.example.com can be browsed as subdomain.example.com i tried few condition but they were redirecting to main domain. I am using codeigniter framework (may be not relevent )
Upvotes: 1
Views: 290
Reputation: 579
You van just add an extra condition.
This should work.
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^subdomain\.example\.com [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE]
Upvotes: 3