.htaccess强制https但只有一页带有http或https

时间:2017-01-09 09:02:08

标签: http redirect ssl https

我想将所有网页重定向到https,不包括一页!

此页 www.domain.com/data/push-send 应通过http://或https://

访问

这是我目前的代码:

RewriteEngine On

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ /$1 [R=301,L]

# enforce a no-trailing-slash policy
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Redirect api to data/push-send
RewriteRule ^api$ data/push-send [qsappend,L]

# no index in URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^(.*)$ http://www.domain.com [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
RewriteRule ^(.*)$ http://www.domain.com [L,R=301]

# force https
RewriteCond %{SERVER_PORT}   !^443$
RewriteRule  (.*)  https://%{HTTP_HOST}/$1   [R=301,qsappend,L]

我该怎么做

谢谢Kevin

1 个答案:

答案 0 :(得分:0)

我是靠自己得到的

# force https
RewriteCond %{SERVER_PORT}   !^443$
RewriteCond %{REQUEST_URI} !data/push-send [NC]
RewriteRule  (.*)  https://%{HTTP_HOST}/$1   [R=301,qsappend,L]

凯文

相关问题