Reputation: 13
In an application I want all users to start at index.php. So I want to redirect all direct URLs to other pages to this file.
When I use the following syntax, only the non-existing files are rewritten, but I want to redirect the existing URLs too.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
Upvotes: 1
Views: 89
Reputation: 1051
RewriteCond %{REQUEST_FILENAME} !-f
means: if this file does not exist, apply the RewriteRule.
RewriteCond %{REQUEST_FILENAME} !-d
means: if this directory does not exist, apply the RewriteRule.
Use:
RewriteEngine on
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
EDIT:
If you want to redirect only when the URL does not start with /index.php
yet, use this extra condition:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php/?path=$1 [NC,L,QSA]
Upvotes: 3