SOに関するこの一般的なトピックに関する多くの質問を読みましたが、私の問題を解決する解決策を得ることができないようです。
ExpressionEngineを使用しており、 https://の背後に1つのセクションのみが必要です。残りのWebサイトでhttps://リクエストをhttp://にリダイレクトする必要があります。
例1: http: //test.com/facebook 301 httpsにリダイレクト: //test.com/facebook
例2: https://test.com/test_page/ 301 http://test.com/test_page/にリダイレクト
注: / facebookはサーバー上のディレクトリではなく、ExpressionEngine内のテンプレートグループです。
これが私のこれまでの.htacessです:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Force SSL on facebook pages
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^/facebook
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC]
RewriteRule ^(.*)$ https://%2/$1 [R=301,L,QSA]
# Remove SSL on other pages
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/facebook
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]
# Remove www. from URLs
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Magic ExpressionEngine rule to remove index.php requirement from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
現在の問題: 例2は正常に機能し、https://を含むURLはhttps://を削除しています。
ただし、 http://test.com/facebookにアクセスすると、 http : //test.com/ index.php /facebookにリダイレクトされます。つまり、HTTPSがなく、index.phpが追加されています。
.htaccessファイルは2回実行されていると考えられます。最初は最初のブロックにヒットしてリダイレクトされますが、その後「index.php」が追加され、2番目のブロックにヒットするため、https:/が削除されます。 /。
どんな助けでも大歓迎です。
ありがとう!
ライブHTTPヘッダーレポート
http://test.com/facebook/register
GET /facebook/register HTTP/1.1
HTTP/1.1 301 Moved Permanently
Date: Thu, 20 Dec 2012 17:20:17 GMT
Server: Apache
Location: https://test.com/facebook/register
--------
http://test.com/index.php/facebook/register
GET /index.php/facebook/register HTTP/1.1
HTTP/1.1 200 OK
Date: Thu, 20 Dec 2012 17:20:17 GMT
Server: Apache