1

Let's say I have a website xxxx.com/ and I want to redirect any pages to https, except pages with /admin/, for example xxxx.com/admin/xxx.php will use http.

I tried to follow How to force rewrite to HTTPS except for a few pages in Apache?

and I came up with this

RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^\/admin\/
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]    

RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} ^\/admin\/ 
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]

but this is not working, I typed xxxx.com/admin and it redirected to https://xxxx.com/cgi-bin/php55.cgi/admin/index.php

How do I solve this?

Community
  • 1
  • 1
Joshua Leung
  • 2,219
  • 7
  • 29
  • 52
  • 1
    `/admin` is not the same as `/admin/`. Had you tried `xxxx.com/admin/` it would have worked. Make the trailing slash optional so it works on both `/admin` and `/admin/`. Change `RewriteCond %{REQUEST_URI} !^\/admin\/` to `RewriteCond %{REQUEST_URI} !^\/admin[\/]`. – alvits Aug 22 '16 at 22:59

0 Answers0