How can I remove \'web/app_dev.php/\' from my url when I want my symfony website to go live?
This is the default url during development,
http://{loca
To hide app.php
you need to:
mod_rewrite
module installed and enabled in Apache looking the phpinfo()
under "apache2handler" ---> "Loaded Modules" directory (you should have that possibility directly through the control panel).After these checks you have to:
NOTE: Symfony2 already comes with an .htaccess
file stored in the default web directory but if you don't know what are you doing it's better to replace the directives containet within the "IfModule mod_rewrite.c" with those shown below.
Use the native Symfony2 .htaccess
or create a new one file with the .htaccess
extension and copy/paste inside these directives to hide app.php
in production (not on localhost):
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
RewriteRule .? - [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ app.php [QSA,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule .? %{ENV:BASE}app.php [L]
# and from the symfony's original
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
# RedirectTemp cannot be used instead
To apply the modifications you need to restart Apache (also this is usually did on the control panel of your web space).
Googling a bit you can find tons of examples and tutorials but to start to learn take a look at this simple .htaccess guide with many useful infos and examples and the Official URL Rewriting Guide (Apache2.4). If you encounter some problem update your post adding all related infos otherwise you can make another question here on SO.