[英].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.