[英].htaccess - how to redirect https:// to http:// for specific url
[英]I want to redirect specific url to non https using htaccess
我目前的 htaccess 是:-
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
</IfModule>
我想为像https://www.example.com/abc/arg1/arg2
这样的 url 添加规则到 htaccess 应该重定向到http://www.example.com/abc/arg1/arg2
这个https://www .example.com/abc/ * 它应该重定向到非 https 格式并保留所有参数。
使用以下规则,清除缓存后检查。
RewriteCond %{REQUEST_URI} ^/abc/(.*) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
编辑:请尝试以下规则,
RewriteCond %{REQUEST_URI} !^/abc/(.*) [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
在上述规则中,我们将 https 附加到所有不以abc/(.*)
开头的 url,您必须在原始 https 规则存在的地方使用此rewritecond
。
我不确定你是如何完成这项工作的,但以下内容应该非常适合你。
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/abc [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.