3
我有一個Apache虛擬主機偵聽端口:443UN-HTTPS與國防部重寫特定的URL
我試圖重定向任何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
謝謝。現在有道理 – Scott 2012-08-14 07:59:22