2016-03-21 22 views
0

私は1日以上私を悩ませている問題があります。htpasswd認証を使用するとhtaccessリダイレクトに失敗しました

基本的なhtpasswdログインを使用しているcmsと呼ばれるサブディレクトリが設定されています。 メインサイトへのすべてのリクエストは、htaccessを使用してindex.phpにリダイレクトされます。cmsにはのリクエストを除いて、フォルダー、イメージなどが要求されます。

これはwww_rootで、次のhtaccessでの結果:CMS -folderインサイド

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteCond %{HTTP_HOST} !^www\.domain\.nl [NC] 
RewriteRule ^(.*)$ https://www.domain.nl/$1 [R=301,L] 

RewriteCond %{REQUEST_URI} !^/cms 
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.css|\.js|favicon\.ico|\.svg|\.pdf|\.ino)$ [NC] 
RewriteCond %{REQUEST_URI} !^/robots.txt$ [NC] 
RewriteCond %{REQUEST_URI} !^/BingSiteAuth.xml$ [NC] 
RewriteCond %{REQUEST_URI} !^/apple-app-site-association$ [NC] 
RewriteRule (.*) framework/index.php [L] 

は認証のみのものを含む、別のhtaccessファイルです:

AuthName "CMS" 
AuthUserFile /path/to/.htpasswd 
AuthGroupFile /dev/null 
AuthType Basic 

require valid-user 

問題がありますcms/index.phpをリクエストすると、リクエストはframework/index.php 01にリダイレクトされます代わりにCMS/index.phpをの、RewriteCond %{REQUEST_URI} !^/cmsがメインhtaccessファイルではありませんように、私はすべてが、正常動作していると私は(今保護されていないに到達することができるよ、その場合には、CMS/.htaccessのを、削除する場合を除き、 )CMS。

このサイトは、Apache 2.4.16およびPHP 5.6を使用して、Redhat Linuxサーバーで実行されています。

答えて

0

は何が起こっているのか見てデバッグログをオンにしてみてください。

RewriteLog "/tmp/debug.log" 
RewriteLogLevel 6 

サイトのURLをステップとして、ログはルールが一致し、なぜしているかを紹介します。私はそれを設定し、/tmp/debug.logを見たときに

例えば、私はこの要求(/somedirectory)が書き換えられたことを見ることができました:

(4) RewriteCond: input='/somedirectory' pattern='!^/cms' => matched 
(2) rewrite '/somedirectory' -> 'framework/index.php' 
(2) local path result: framework/index.php 

と、この要求(/cms)に書き換えられていなかった。

(2) init rewrite engine with requested uri /cms/index.php 
(3) applying pattern '(.*)' to uri '/cms/index.php' 
(4) RewriteCond: input='/cms/index.php' pattern='!^/cms' => not-matched 
(1) pass through /cms/index.php 
関連する問題