Forum Moderators: phranque
The following rewrite rule redirects successfully to HTTPS (visible in the FireFox URL line).
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^(.*)/myweb/myniche/(.*)$
RewriteRule ^(.*)$ $1__SEPARATOR__%{SERVER_NAME} [C]
RewriteRule ^(.*)__SEPARATOR__(.*)$ [$2$1...] [L,R=permanent]
However, the HTTPS request then gets stuck in an infinite loop --
Redirect Loop ..
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
(The looping is verified in defaultApacheRewrite.log too.)
The first condition should fail for the redirected HTTPS request and
let it pass, but it does not.
I have also tried
RewriteCond %{SERVER_PORT} !^443$
and
RewriteCond %{SERVER_PORT} ^80$
but none of them works.
Any suggestions/ideas? Thanks in advance.
Try using "%{SERVER_PORT} !^443$" instead.
Also, I see no reason why the REQUEST_URI RewriteCond and the chained rule are needed -- it's over-complicated. Do it all at once with something like:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*/myweb/myniche/.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Since you didn't provide example request URL-paths, all I can do is make that general recommendation...
Jim