Reputation: 13
I have a problem with .htaccess configuration. I know how to ignore file extensions (e.g. php). That's my code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
But I want to ignore specific a subfolder in the URI.
For example, I have a file in example.com/sites/test.php
but in the address bar, I just want to type example.com/test
. Any ideas?
Upvotes: 1
Views: 109
Reputation: 785531
You can use:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/sites/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /sites/$1.php [L]
Upvotes: 0