将https重定向/重写为除一页之外的http

时间:2015-08-11 11:23:52

标签: php .htaccess rewrite

除了一页,我想将https重定向到http

我需要什么:

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

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

resultant页面与https匹配时,它仍然在https

到目前为止我尝试了什么:

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

但它没有将所有其他页面重定向到http

我的HTACCESS代码

#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>

由于

1 个答案:

答案 0 :(得分:1)

您可以使用:

RewriteEngine On

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