简体   繁体   中英

Redirect all https to http, except 3 pages [htaccess / php]

Running a wordpress site, therefore it already has its own rule to remove index.php from links. Furthermore, every time in a url there is "cache_img", a specific rule applies.

What I need:

  1. for the current rules to keep working
  2. in case a url is in https, rewrite it with http (301), EXCEPT 3 pages (bookingstep1, bookingstep2, bookingsep3)

I suck at htaccess, it makes little to no sense to me, I hope someone can help me with this. I'm open to either htaccess or php solutions.

This is what I have at the moment (and it may already have mistakes in it...)

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(cache_img) [NC]
RewriteRule . /index.php [L]
RewriteRule ^cache_img/(.*)x(.*)-(.*)/r/(.*) cache_img/tt.php?src=http://mydomain.com/$4&w=$1&h=$2&zc=$3&q=100

I tried with adding at the top of my htaccess:

RewriteCond %{HTTPS} on
Rewritecond %{REQUEST_URI} !^bookingstep(1|2|3)\/?$ [NC]
RewriteRule ^(.*) http://mydomain.com/$1 [R=301,L]

Which works for all pages... it removes the https and rewrites them with http. But it also rewrite the bookinstep* pages :(

Please help! Thank you!

Give this plugin a go:

http://wordpress.org/plugins/wordpress-https

I personally use it all of the time. You can make every page https or can go into individual pages/posts and just make those individually secure.

EDIT

RewriteEngine on
RewriteCond %{SERVER_PORT} =80
RewriteRule ^bookingstep1/?$ https://URL HERE/bookingstep1[R=301,QSA,L,NE]
RewriteRule ^bookingstep2/?$ https://URL HERE/bookingstep2[R=301,QSA,L,NE]
RewriteRule ^bookingstep3/?$ https://URL HERE/bookingstep3[R=301,QSA,L,NE]

Redirect all https to http

Code:

RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} on
RewriteRule  ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

For More Details see here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM