我試圖將一些安全頁面添加到網站。站點中的鏈路全部使用當前協議(即獨立於協議,路徑始於//
)。http/https重寫不工作,將index.php添加到路徑
我需要路徑/info/season-tickets/*
和/ticketcontroller/*
來使用https,以及所有其他使用http。
我試圖建立規則(目前忽略ticketcontroller部分)做到以下幾點:
If Port==80 and Path==/info/season-tickets/, rewrite with https
If Port==443 and Path!=/info/season-tickets/, rewrite with http
然而,當我訪問/info/season-tickets/
,而不是重定向到HTTPS版本,我得到example.com/index.php/info/season-tickets
的的.htaccess低於 - 我嘗試低於# Force https on certain pages
和# Force http everywhere else
,另位是從Kohana的框架
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase/
# Force https on certain pages
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/info/season-tickets/?
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
# Force http everywhere else
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} !^/info/season-tickets/?
RewriteRule ^(.*)$ http://www.example.com/$1 [R,L]
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
我試着重新排列規則,看看是否修正了它,但沒有。
任何想法,爲什麼這不工作(http://htaccess.madewithlove.be/
表明,它應該工作)...
謝謝!