简体   繁体   中英

Redirect / Rewrite https to http except one page

I want to redirect https to http except one page.

What I need:

https://abc.subdomain.com/testing1
https://abc.subdomain.com/testing2
https://abc.subdomain.com/resultant

to

 http://abc.subdomain.com/testing1
 http://abc.subdomain.com/testing2
 https://abc.subdomain.com/resultant

when resultant page hit with https it remains on https

What I have tried so far:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/resultant
RewriteRule ^/resultant https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L]

but it is not redirecting all other pages to http

MY HTACCESS CODE

#AuthType Basic
#AuthName "sentineldev DEV VERSION"
#AuthUserFile /home/sentineldev/public_html/.htpasswd
#Require valid-user
#ErrorDocument 401 "Unautorized Access"
Options +Indexes -MultiViews
RedirectMatch 403 ^/wp-includes/$
RedirectMatch 403 ^/wp-content/$

#------------------------------


RewriteEngine On

RewriteCond %{HTTPS} on
NRewriteCond %{THE_REQUEST} !/resultant
RewriteRule !^resultant(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]



#------------------------------



Header set X-Frame-Options SAMEORIGIN
# Turn on IE8-IE9 XSS prevention tools
Header set X-XSS-Protection "1; mode=block"


# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
<IfModule mod_php5.c>
   php_value upload_max_filesize 2M
   php_value post_max_size 3M
</IfModule>

Thanks

You can use:

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !/resultant [NC]
RewriteRule !^resultant(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,NC]

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