Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure .htaccess to work on a PHP Framework (Silex)

I have a working path on my Apache2 localhost (linux):

http://localhost/lab/silex/web/index.php/hello/name

I want to become:

http://localhost/lab/silex/hello/name

Now I have Rewrite mode enabled and tested.

I have placed my .htaccess file in my silex/web folder:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteBase /web/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

I still cannot see the clean url working.

like image 346
Kandinski Avatar asked Dec 15 '13 04:12

Kandinski


2 Answers

in your main folder try this: (for you this would be the silex folder)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ web/$1 [QSA,L]
</IfModule>

and in the web folder:

<IfModule mod_rewrite.c>
    Options -MultiViews

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

    RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /web/
RewriteRule ^(.*)$ /$1 [L,R=301]
</IfModule>
like image 184
Kristof Feys Avatar answered Nov 14 '22 12:11

Kristof Feys


Try this code in your DOCUMENT_ROOT/.htaccess file:

Options -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_URI} !/lab/silex/web/index\.php/ [NC]
RewriteRule ^(.*)$ /lab/silex/web/index.php/$1 [L]
like image 26
anubhava Avatar answered Nov 14 '22 12:11

anubhava