Reputation: 1
I have created a subdomain in my GoDaddy cPanel and want to work on it as a dev site. In my htaccess, which is within the public_html directory, I have some code to do two things: redirect www to non-www and redirect http to https:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
# END Force SSL
# BEGIN Force HOSTNAME
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301,NC]
# END Force HOSTNAME
The problem is that it redirects my subdomain, which should be subdomain.example.com to example.com/subdomain/
How do I continue to redirect http to https and www to non-www on my main domain, but disable this redirect on the subdomain? It would be nice to keep https on the subdomain, but is not needed.
If I remove the force hostname code, the subdomain works (as such: subdomain.example.com), but no longer redirects www to non-www.
Upvotes: 0
Views: 54
Reputation: 1
Needed to add an additional RewriteCond
to the force SSL section:
RewriteCond %{HTTP_HOST} ^(.)?example\.com
Upvotes: 0