5

this one has me buggered- I have the below htaccess rule to redirect ssl to non-ssl pages. this works fine, except I'd like to exclude certain wordpress requests from this rule- for example, https://mysite.com/info/. I've tried the following:

#rewrite all ssl pages to non-ssl for everything that doesn't have /info/ in the request uri 
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/info/
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]

#wordpress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

the result is that https://mysite.com/info/ redirects to http://mysite.com/ instead. If I disable the wordpress rewrite rules, the preceding rules work fine. Can anyone suggest the proper way to target pretty urls in a rewrite condition?

5
  • Did you ever figure this out?
    – jetlej
    Commented Jul 2, 2015 at 17:21
  • Move the question to stackover community. This need expert .htaccess advice. Also shared the question on Facebook closed group. Lets see. Thanks
    – Vee
    Commented Jul 3, 2015 at 9:29
  • @jetlej Is your https://example.com/info/ an unexisting one? Commented Jul 3, 2015 at 16:05
  • @5ervant - Yes it's an existing page
    – jetlej
    Commented Jul 3, 2015 at 19:46
  • 1
    @Vee - Thanks for the advice. I did this and got an answer! stackoverflow.com/questions/31213450/…
    – jetlej
    Commented Jul 3, 2015 at 23:16

1 Answer 1

3

Edit your existing code to exclude the index.php from redirecting like this:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/info/
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]

For an explanation, check the answer to this question at Stackoverflow: Issue with .htaccess redirecting all pages to HTTPS except one .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.