Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove index.php from slim framework URL

i'm trying to remove index.php form an URL:

this works

http://server/bw/index.php/test

this doesn't work

http://server/bw/test

i try to change .htaccess and watching on web i see that it should be like this:

RewriteEngine On
RewriteBase /bw/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

i try editing it in this way:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

or in this way:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /bw/index.php [QSA,L]

or in this way:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d

But when i try to access to http://server/bw/test it says me:

Not Found

The requested URL /bw/test was not found on this server.

Apache/2.2.15 (CentOS) Server at server Port 80

I check that inside my httpd.conf LoadModule rewrite_module modules/mod_rewrite.so is enable.. i don't know what to do now..

how can i solve? please help me!

like image 761
Jayyrus Avatar asked Jan 08 '13 22:01

Jayyrus


1 Answers

Try this, which used e.g. in WordPress

RewriteRule . index.php [L]

or this, which is used by e.g. Lavavel PHP Framework

RewriteRule ^(.*)$ index.php/$1 [L]

You might also consider adding

RewriteCond %{REQUEST_FILENAME} !-d

before the RewriteRule to also exclude existing directories, not only existing files. But that's up to you.

like image 174
Dehalion Avatar answered Oct 18 '22 09:10

Dehalion