从https重定向到http几页htaccess

时间:2014-12-19 10:01:11

标签: .htaccess

我在我的知识中遵循以下代码:

RewriteRule ^productdetails/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+) /singlepro.php?cat=$1&sub=$2&fur=$3&name=$4&data=$5/

如果某人已在https页面上,则上述代码会重定向到https版本。如果我写下面的代码:

RewriteRule ^productdetails/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+) http://www.example.com/singlepro.php?cat=$1&sub=$2&fur=$3&name=$4&data=$5/

它将网址显示为http://www.example.com/singlepro.php?cat=aaa&sub=aaa&fur=aaa&name=aaa&data=aaa/。我想重定向到http加上它应该显示URL为/productdetails/../../ .. 知道可以做些什么吗?

htaccess文件

RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^xyz\.php$ https://www.example.com/xyz.php [L,R=301]
RewriteRule ^productdetails/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)
            /singlepro.php?cat=$1&sub=$2&fur=$3&name=$4&data=$5/

对于像xyz.php这样的某些页面,我将它们重定向到https。

1 个答案:

答案 0 :(得分:0)

如果我理解得很好。添加到.htaccess

之上
RewriteCond %{HTTPS} on
RewriteRule ^productdetails/ http://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]