Diogo Braga
Diogo Braga

Reputation: 233

Apache mod_rewrite ignore some real directories

That's my root directory:

css
img
js
includes
templates
api

and that's my .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?ur=$1 [L,QSA]

It works fine but when I inform the url a directory exists, the Apache open the directory, when in fact it should inform the URI for ur parameter.

For example: mydomain.com/test-uri/ goes to ur parameter. mydomain.com/api/ apache loads the api directory.

I did some research, but the most we got was to consider all directories when I need only pass the api directory as parameter.

Upvotes: 1

Views: 28

Answers (1)

Jon Lin
Jon Lin

Reputation: 143946

Remove the -d check:

RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?ur=$1 [L,QSA]

Upvotes: 1

Related Questions