Reputation: 983
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.
Upvotes: 5
Views: 5845
Reputation: 1842
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>
Upvotes: 10
Reputation: 785068
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]
Upvotes: 2
Reputation: 983
I found a code that works, but still only for /silex/web/hello/name. I want to make it work for /silex/hello/name
<IfModule mod_rewrite.c>
Options -MultiViews -Indexes
RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
Upvotes: 0