Forum Moderators: phranque
This is in my htaccess:
# Redirect pages to SSL and non-SSL to HTTP
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(user¦cart¦admin) [%{HTTP_HOST}%{REQUEST_URI}...] [R=301,L]
RewriteCond %{HTTPS} !=off
RewriteRule ^/?(content¦category¦catalog) [%{HTTP_HOST}%{REQUEST_URI}...] [R=301,L]
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I wanted to know if it's possible to rewrite the second part of these rules so if the requested page is anything but /user /cart /admin then it goes to HTTP. This is because at current the root of the site isn't redirected to the HTTP.
Any help will be greatly appreciated!
I did try that earlier today as it seemed to be logical but it only works if you are on a https page and you navigate to a non https page.
If you are on http and want to go to /user it gets stuck in a redirect loop and goes to /index.php?q=user. Same with the /admin and /cart pages.
I think it's conflicting with this that was already in the htaccess before I amended it:
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I'm a noob at this i've spent a couple of days already trying to work this out!
Exclude internal redirects and subrequest lookups
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteCond %{HTTPS} =off
RewriteRule ^/?(user¦cart¦admin) [%{HTTP_HOST}%{REQUEST_URI}...] [R=301,L,NS]
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteCond %{HTTPS} =on
RewriteRule !^/?(user¦cart¦admin) [%{HTTP_HOST}%{REQUEST_URI}...] [R=301,L,NS]
[edited by: jdMorgan at 2:15 pm (utc) on Jan. 27, 2009]
[edit reason] Corrected as noted in subsequent post [/edit]
None of the /cart /admin or /user pages are redirected to HTTPS. If you add in the s manually in the address bar then these pages are redirected to HTTP like the other pages.
Could I possibly have them in the incorrect order?
Completely flush (or disable) your browser cache before testing new server-side code.
Some servers seem to work better using "RewriteCond %{SERVER_PORT} =443" instead of "RewriteCond %{HTTPS} =on"
Jim
[edited by: jdMorgan at 2:20 pm (utc) on Jan. 27, 2009]
This is due to an error in ubercart and how it processes the ajax - not with the rewrite code shown in this thread.
Even if you can't fix all of the SSL<->non-SSL problems, fixing most of them will probably help a lot.
Jim