Cilenco
Cilenco

Reputation: 7117

htaccess does not work properly

On my WebServer I have a htaccess file which looks like this:

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

So all calls to my WebServer are redirected to the index.php file in my root directory with a path parameter which holds the requested file. Now look at these two calls:

domain.com/test/blub.php        works -> path = test/blub.php
domain.com/test/                does not work -> path should be test

How can I achieve the the second call also works?

Upvotes: 2

Views: 36

Answers (1)

anubhava
anubhava

Reputation: 784888

Remove this condition from your rule:

RewriteCond %{REQUEST_FILENAME} !-d

As this is skipping all real directories from this rule.

Use your rule as:

DirectorySlash Off
RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,NE]

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

Upvotes: 2

Related Questions