如何将两个wordpress页面重定向到https?

时间:2012-05-02 22:39:48

标签: wordpress .htaccess redirect ssl https

我的网站上安装了SSL证书,我想将两个特定页面重定向到https,例如http://domain.com/?page=credit and http://domain.com/?page=submit_form到https。

我的网站托管服务商将以下代码添加到我的.htaccess文件中,高于Wordpress设置,但它仍然没有重定向页面:

Redirect /?page=credit https://domain.com/?page=credit

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{QUERY_STRING} (^|&)p=(credit)($|&)
RewriteRule (.*) https://domain.com/?page=credit [R=301,QSA,L]

对不起,我不太擅长这个。我将获得任何帮助。

感谢。

1 个答案:

答案 0 :(得分:0)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{QUERY_STRING} (^|&)page=(credit|submit_form)(&|$) [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} =on
RewriteCond %{QUERY_STRING} !(^|&)page=(credit|submit_form)(&|$) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]