0
1
I have an internal domain: cloud.flint.lo
I would like to achieve the following:
If URL=http://cloud.filnt.lo
Redirect to: https://cloud.flint.lo:5001/sub
If URL=https://cloud.flint.lo
Redirect to: https://cloud.flint.lo:5001
I wrote this in .htaccess, but only the first scenario works:
RewriteEngine On
RewriteCond %{SERVER_PORT} !^5001$
RewriteRule ^(.*)$ https://%{HTTP_HOST}:5001/$1 [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}:5001/sub [L,R=301]
I also tried to use "REQUEST_URI" to match the 5001 port but didn't work either.
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^.*\:5001
RewriteRule ^(.*)$ https://%{SERVER_NAME}:5001/sub [L,R=301]
The second example didn't work either. And I am still prefer the mod_rewrite method because the website may move to webhosting in the future. – NeilWang – 2019-12-16T01:53:36.620
I have added mod_rewrite options. However, please note that all the suggestion given should work. If the added examples do not work for you, there may be additional issues you are facing. – Anaksunaman – 2019-12-16T05:38:58.393
You may also wish give more specifics about the problem(s) you are encountering. – Anaksunaman – 2019-12-16T05:53:20.013
Both of the methods works now. Thank you @Anaksunaman! – NeilWang – 2019-12-18T00:29:27.963
Glad to hear it. You're welcome. =) – Anaksunaman – 2019-12-18T00:30:43.420