2016-03-20 20 views
1

を持つ単一のページへのHTTPアクセスを制限しますか?いくつかのバリエーションが許容してここ 私はこの<code>.htaccess</code>ファイルを持っているの.htaccess

が、私は期待して行動の一例である(例えば /https-required.htmlのみは、HTTP経由で提供できるのであれば、それは許容範囲だ):

http://www.ex.com/      => http://www.ex.com/https-required.html 
http://www.ex.com/valid-page.html  => http://www.ex.com/https-required.html 
http://www.ex.com/invalid-page.html => http://www.ex.com/https-required.html 
http://www.ex.com/https-required.html => http://www.ex.com/https-required.html 

https://www.ex.com/     => https://www.ex.com/ 
https://www.ex.com/valid-page.html  => https://www.ex.com/valid-page.html 
https://www.ex.com/invalid-page.html => https://www.ex.com/404.html 
https://www.ex.com/https-required.html => https://www.ex.com/https-required.html 

私がしたいですサイト全体をHTTPSに制限しますが、そのためには必ずHTTPアクセス試行を考慮する必要があります。

SSLRequireSSL 

など、HTTPを完全に無効にすることはできますが、偶発的なHTTPアクセスでは悲惨な体験になります。この問題に対するより一般的な解決策は、単に

Redirect permanent/https://www.example.com 

または

RewriteCondition %{SERVER_PORT} !^443$ 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] 

ようなものでhttps://http://をリダイレクトすることですが、私は特にこのリダイレクトを回避するために探しています。

答えて

1

あなたはこのようにそれを使用することができます:

Options -MultiViews 
RewriteEngine On 

RewriteCond %{HTTPS} off 
RewriteRule !^https-required\.html$ /https-required.html [L,NC,R=302] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule^index.php [L] 
関連する問題