0

安全なページをサイトに追加しようとしています。サイト内のリンクはすべて現在のプロトコルを使用します (つまり、プロトコルに依存せず、パスは で始まります//)。

https を使用するためのパス/info/season-tickets/*/ticketcontroller/*、http を使用する他のすべてのパスが必要です。

次のことを行うルールを作成してみました (今のところ、チケットコントローラーの部分は無視します)。

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/機能するはずであることを示しています)...

ありがとう!

4

1 に答える 1

0

この問題は htaccess ではなく index.php ファイルで解決しました (すべてのリクエストはこれを通過します)。

デフォルトでは、 port を想定しています80。次に、$_SERVER['REQUEST_URI']が安全なパスの配列にある場合は、変数を に切り替えます443

次に、 の場合$required_port != $_SERVER['SERVER_PORT']、リダイレクトしてexit().

于 2013-01-16T13:26:47.507 に答える