Harshad M
Harshad M

Reputation: 363

Symfony .htaccess rewrite and redirect not working

I know very little about symfony framework. I copied a website www.example.net to www.example.com site works with url

www.example.com/www/app.php
or even with
www.example.com/www/
but I want it to redirect automatically to app.php without showing it in the url. My htaccess in the www (web) directory is as follows:

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

It doesn't redirect.

Thanks

Upvotes: 0

Views: 2285

Answers (3)

John the Ripper
John the Ripper

Reputation: 2439

A bit late to this game but I just found an Apache directive that saves so much time and makes your htaccess cleaner. The only caveat is you must have Apache 2.2.16+. To have all urls except valid files (images, etc) use app.php as a front controller use the FallbackResource directive.

<Directory "/web/symfony-project">
    FallbackResource /app.php
</Directory>

Upvotes: 0

Tanguy Bernard
Tanguy Bernard

Reputation: 274

In your Vhost:

Change this line (Directory section):

AllowOverride None

to:

AllowOverride All

Upvotes: 1

anubhava
anubhava

Reputation: 785991

Instead of that rule can you try:

RewriteBase /www/
RewriteRule ^((?!app\.php).*)$ app.php/$1 [NC,L]

Sorry I can't test with Symphony as I am not near my home computer.

Upvotes: 0

Related Questions