0

ルート ディレクトリに codeigniter をインストールしており、htaccess を使用して "test" パスワードで保護されたサブディレクトリを作成したいと考えています。何を試しても「404ページが見つかりません」というメッセージが表示されます。ディレクトリ構造は次のとおりです。

/public_html  
    /css  
    /images
    /system (codeigniter directory)
    /test
        .htaccess
.htaccess
.htpasswd
index.php

ルート .htaccess ファイルは次のようになります。

RewriteEngine On
RewriteBase /

Options -Indexes    

# Removes trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

# Enforce www
RewriteCond %{HTTP_HOST} !^(www) [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]


#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(.*)test(.*)    
RewriteRule ^(.*)$ index.php?/$1 [L]

/test/.htaccess ファイル:

AuthUserFile /home/dir/.htpasswd
AuthName "Protected Area"
AuthType Basic
<limit GET POST PUT>
  require user adminuser
</limit>

URL「 http://www.mydomain.com/test/ 」に移動すると、認証プロンプトも表示されず、 codeigniter 404 ページが表示されます。

お知らせ下さい!

4

2 に答える 2

2

これが私が最終的にそれを解決した方法です(http://codeigniter.com/forums/viewthread/56677/P15/のCodeIgniterフォーラムで解決策を見つけました):

私は私のルートhtaccessにこの行を持っていました:

RewriteCond $1 !^(401.shtml)

したがって、ルートhtaccessの最後のブロックは次のようになります。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(401.shtml)
RewriteRule ^(.*)$ index.php?/$1 [L]

だから安心した解決策がそこにありました。

于 2010-04-07T13:22:38.897 に答える
0
RewriteCond $1 !^(index\.php|addFoldersHere)

メインの .htaccess の現在の RewriteCond ルールの代わりにこれを試してください。これにより、指定したフォルダー (と表示されている場所addFoldersHere) が無視されなくなります。|フォルダーのリストの後に末尾を追加しないでください。

于 2010-04-05T14:29:29.790 に答える