2011-12-19 12 views
1

私は以下のコードを含む.htaccessファイルを持っています。.htaccessが正しく動作しません

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?q=$1 [L] 
RewriteRule ^imagefactory/(.*)$ imagefactory/index.php?q=$1 [QSA] 

私は以下の要件を満たす.htaccessファイルが必要です。 の場合 1)url/admin次にadminフォルダに移動し、.htaccessファイル を選択します。2)url/imagefactory次にimagefactoryフォルダに移動し、index.phpというファイルを選択します。 3)url/index.phpファイル

+0

を試してみてください?もしそうなら、.htaccessではなく、仮想ホストと ''ステートメントを使用してください。 – fge

+0

ユーザがurlに行く場合はfyi、それ以外のWebサーバについてはわからないapacheを使用している場合は、デフォルトでindex [php、html、etc]になります。 他のものについては、リダイレクトを行う必要があるかもしれません。なぜなら、両方で有効なiircとなることを意味するからです。したがって、私は:url/adminとurl/this/is/my/admin/folderの両方が有効であることを意味します。 – DarkMantis

答えて

1

では、Apacheサーバを完全に制御を持っています。この

RewriteEngine on 
RewriteRule ^imagefactory/(.*)$ imagefactory/index.php?q=$1 [QSA] 
RewriteRule ^admin/.$ - [PT] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?q=$1 
+0

ShoogleたくさんのThanx ..このコードは正しく動作しています.. – meghshah

0

最後のルールを1位上にする必要があります。このルールRewriteRule ^(.*)$ index.php?q=$1 [L]はすべてと一致し、[L]属性は他のルールが一致したときに評価されないことを意味します。下のように並べ替えるとうまくいくはずです。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^imagefactory/(.*)$ imagefactory/index.php?q=$1 [QSA] 
RewriteRule ^(.*)$ index.php?q=$1 
0

.htaccessファイルは順番に読み込まれます。 RewriteCondは1つのルールに対してのみ意味します。

は、そのために必要なものは次のとおりです。

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^imagefactory/(.*)$ imagefactory/index.php?q=$1 [QSA, L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/admin/(.*)$ 
RewriteRule ^(.*)$ index.php?q=$1 [QSA, L] 

第2のブロックがキャッチすべてですので、そのないディレクトリの管理者から、デフォルトのルートのindex.phpを使用する場合に。

+0

それは次のようなエラーを出します:Internal Server Error – meghshah

関連する問題