Apache 重定向到https条件
如果没有“mob”后缀,我想将我的用户重定向到https 示例: 如果url=then不重定向到https 如果url=重定向到https 如果url=重定向到https 我尝试了以下代码,但没有成功Apache 重定向到https条件,apache,.htaccess,Apache,.htaccess,如果没有“mob”后缀,我想将我的用户重定向到https 示例: 如果url=then不重定向到https 如果url=重定向到https 如果url=重定向到https 我尝试了以下代码,但没有成功 RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} !^/(.*)/mob$ RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 请使用
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/(.*)/mob$
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
请使用变量
尝试此规则:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} !/mob[/?\s] [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
确保在新浏览器中测试或清除浏览器缓存以避免旧缓存
建议您将此规则作为首要规则