I've been scouring Google to find a similar situation but haven't been successful yet, so I turn to get help from the [H] crew.
Currently, our .htaccess file redirects any non https URL to an https URL enabling the entire site to be secure. This has been great and has been working fine for quite some time.
Now, the only issue is we need to add an exception to the normal URL forward so instead of just slapping the s onto it and keeping the main URL as the root, we need a subdomain to preface the root URL but still keep the s for secure purposes.
Here's what I have with examples, and hopefully it'll make more sense:
If I type in http://www.example.com, I'll get redirected to https://example.com (Good!)
If I type in https://www.example.com, I'll get redirected to https://example.com (Good!)
If I type in http://www.example.com/subdomain (Not good, because it won't add the https for SSL. I want it to redirect to https://subdomain.example.com)
If I type in https://www.example.com/subdomain, I'll get redirected to https://example.com (Not good, because adding the https manually removes the subdomain altogether)
If I type in https://subdomain.example.com, it goes to that, and stays as is (Good!)
If I type in https://subdomain.example.com/index.htm, it'll go to that file and stay as is (Good!)
Basically, I need to get those 2 exceptions figured out. Can anyone assist please?
Thank you (and apologies in advance for any confusion).
Currently, our .htaccess file redirects any non https URL to an https URL enabling the entire site to be secure. This has been great and has been working fine for quite some time.
Now, the only issue is we need to add an exception to the normal URL forward so instead of just slapping the s onto it and keeping the main URL as the root, we need a subdomain to preface the root URL but still keep the s for secure purposes.
Here's what I have with examples, and hopefully it'll make more sense:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://example.com%{REQUEST_URI} [NS,R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com
RewriteRule ^(.*)$ /subdomain/$1 [L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ http://example.com [R=301]
Options -Indexes
If I type in http://www.example.com, I'll get redirected to https://example.com (Good!)
If I type in https://www.example.com, I'll get redirected to https://example.com (Good!)
If I type in http://www.example.com/subdomain (Not good, because it won't add the https for SSL. I want it to redirect to https://subdomain.example.com)
If I type in https://www.example.com/subdomain, I'll get redirected to https://example.com (Not good, because adding the https manually removes the subdomain altogether)
If I type in https://subdomain.example.com, it goes to that, and stays as is (Good!)
If I type in https://subdomain.example.com/index.htm, it'll go to that file and stay as is (Good!)
Basically, I need to get those 2 exceptions figured out. Can anyone assist please?
Thank you (and apologies in advance for any confusion).
Last edited: