1

我想https://在我的网站上仅在这些前缀 url 上创建协议:

dream-portal.net/index.php?page=postratingspro

dream-portal.net/index.php?page=paypaltest

因此,此后 URL 中的任何内容也应包括https://协议。例如:

dream-portal.net/index.php?page=postratingspro;sa=blahblah;testing

我怎样才能做到这一点?尝试了以下方法,但它并没有将我所有的其他网址都转为网站上的 http://。

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} = off
RewriteRule index.php?page=^(postratingspro|paypaltest)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# don't do anything for images/css/js (leave protocol as is)
RewriteRule \.(gif|jpe?g|png|css|js)$ - [NC,L]

# force http for all other URLs
RewriteCond %{HTTPS} = on
RewriteCond %{REQUEST_URI} !page=^/(postratingspro|paypaltest)\$
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

我怎样才能做到这一点,我的代码有什么问题?

4

1 回答 1

1

用这个替换你的代码:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=(paypaltest|postratingspro)[&;,\s] [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} !(^|&)page=(paypaltest|postratingspro)([,;&]|$) [NC]
RewriteRule ^(index\.php)?$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]
于 2013-07-13T17:37:21.907 回答