0

安全なサブドメインの外部で HTTPS が使用されている場合、HTTP にリダイレクトされるようにしています。

これは、ルート .htaccess ファイルにあるものです。

# Redirect HTTPS requests for non-SSL pages back to HTTP. (Note that shared objects
# such as images are excluded from this rule)

RewriteCond %{HTTPS} =on

# my.EXAMPLE.com is the secure subdirectory.
RewriteCond %{HTTP_HOST} !^my.EXAMPLE.com [NC]

RewriteCond $1 !\.(gif|jpe?g|png|ico|css|js)$
RewriteRule ^(.*)$ http://www.EXAMPLE.com/$1 [R=301]

簡単に言えば:

if HTTPS
if not in my.example.com
if NOT an image/css/js file
redirect to HTTP

しかし、これは期待どおりに機能しません。代わりに、HTTPS 経由で my.example.com サブディレクトリの外部にあるページにアクセスしようとすると、404 Not Found エラーが発生します。HTTP 経由で同じページにアクセスしても問題はなく、正常に動作します。

このルールが機能しない理由は何ですか?

編集

.htaccess ファイル全体は次のとおりです。

# Don't display .htacess files in directory listings.
IndexIgnore .htaccess
Options +FollowSymLinks
RewriteEngine on

# Password protected for now
AuthType Basic
AuthName "EXAMPLE"
AuthUserFile "/home/EXAMPLE/.htpasswds/public_html/passwd"
require valid-user

# Redirect HTTPS requests for non-SSL pages back to HTTP. (Note that shared objects
# such as images on both HTTP and HTTPS pages are excluded from this rule)
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^my\.EXAMPLE\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|ico|css|js)$
RewriteRule ^(.*)$ http://www.EXAMPLE.com/$1 [R=301]


# Redirect non-www requests to www
RewriteCond %{HTTP_HOST} ^EXAMPLE.com$
RewriteCond %{HTTP_HOST} !^my\.EXAMPLE\.com [NC]
RewriteRule ^(.*)$ "http\:\/\/www\.EXAMPLE\.com\/$1" [R=301]

# Prevent direct access to the WHMCS folder must be accessed through secure subdomain
RedirectMatch 301 ^/WHMCS/(.*)$ https://my.EXAMPLE.com/$1

    
ErrorDocument 404 /404.php
4

2 に答える 2

0

これを試して :

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^my\.EXAMPLE\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|ico|css|js)$
RewriteRule ^(.*)$ http://www.EXAMPLE.com/$1 [R=301]
于 2012-08-31T08:28:02.583 に答える
0

問題は、 の SSL vhost セットアップがなく、www.example.comそのドキュメント ルートが の非 SSL vhost と同じ場所を指しているwww.example.com場合、誰かが にアクセスしたときhttps://www.example.com/に、htaccess ファイルが読み取られないことです。HTTPS->HTTP ルールを SSL vhost の htaccess ファイル (my.example.comのドキュメント ルートがある場所) に入れる必要があることは間違いありません。

あなたが持っているものは次のようです:

http://www.example.com/ -> /home/EXAMPLE/ (or whatever your document root is)

https://my.example.com/ -> /home/EXAMPLE/subfolder/

そのため、 の vhost をセットアップしないと、SSL example.com にアクセスしたときにhttps://www.example.comの htaccess ファイルにアクセスすることはありません。/home/EXAMPLE/

于 2012-08-31T08:56:41.607 に答える