我有一个 apache vhost 监听端口:443
我正在尝试将任何 https 请求重定向回 http,除非它们满足以下条件
- 从域
www.site.co.uk
- 并包含或
/alpha
包含在请求的/beta
uri 部分
我在配置中有以下语句以及注释逻辑我虽然过程如下,但https://www.mysite.co.uk/alpha
不知https://www.mysite.co.uk/beta
何故被 301'd
我是否误解了条件重写的逻辑流程?
RewriteEngine On
# if host submitted is not 'www.mysite.co.uk' un-https the url (i.e. catchall)
RewriteCond %{HTTP_HOST} !^www\.mysite\.co\.uk [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [NC,L,R=301]
# otherwise IF THE domain is 'www.mysite.co.uk
# *and* if the uri does not contain 'alpha' *or* 'beta' un-https the url
RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.uk [NC]
RewriteCond %{REQUEST_URI} !^\/alpha/? [NC,OR]
RewriteCond %{REQUEST_URI} !^\/beta/? [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [NC,L,R=301]
# otherwise the domain must be www.mysite.co.uk
# and the uri must contain '/alpha' *or* '/beta'
# in which case do nothing