I want to forward everything to index.php except if no file (REQUESTED_FILENAME) was specified or with other words URI is empty or take one /.
I've tried this conditions to rewrite/redirect all to index.php in the .htaccess - file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [QSA]
If I call http://my.dom/test.php, the content of the test.php is displayed (!-f).
Next try: Check, if requested file not index.php and then redirect to index.php
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule ^(.*)$ /index.php/$1 [QSA,R=301]
Ok this works. But i would like no redirect by empty requested file.
Next try: Redirect if requested file is not empty and requested file is not index.php
RewriteCond %{REQUEST_FILENAME} !^$
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule ^(.*)$ /index.php/$1 [QSA,R=301]
If I call http://my.dom/test.php it works fine, redirect to index.php/test.php :D.
If I call http://my.dom or http://my.dom/ its also redirect to index.php. But i would like no redirect by empty requested file.
Update (1) I've now this in my .htaccess.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ / [QSA,R=301]
#this redirect all files to root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /index.php/$1 [QSA,L]
#this rewrite on server side to index.php
This doesn't work. http://my.dom/test.php was redirect to http://my.dom/. But the second rule makes an internal (550) error (every time redirect). I've put a new condition to the first section
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !^/.*$
RewriteRule ^(.*)$ / [QSA,R=301]
#this redirect all files to root
By this: http://my.dom/test.php does not redirect.
Please tell me where my mistake is. And maybe a few solutions.
Regards
REQUEST_URIfor both your conditions, which you said in your first sentence. Also to prevent redirect you need remove the 301 redirect and it be[QSA,L]and this should be thisRewriteCond %{REQUEST_URI} !^/$- Panama Jack