Reputation: 148
I am getting problem in setting custom URL in Symfony-2.3.12. I am new to Symfony. I am using Symfony-2.3.12 in fedora. I have set up application which I can call using the URL
http://localhost/Symfony/web/app_dev.php/sample/hello
I want URL like this:
http://localhost/Symfony/sample/hello
I have read the routing documentation given in Symfony-2.3.12. But could not understand how to do this. Please help me to solve this issue. Thanks in advance.
Upvotes: 0
Views: 180
Reputation: 2607
whether in dev mode or production having mod_rewrite enabled and the directory set to web in the vhost.conf or httpd.conf returns clean urls:
<VirtualHost *:80>
ServerName www.yourSite.com.localhost
ServerAlias yourSite.com.localhost
ServerAdmin yourAdmin@localhost
DocumentRoot /var/www/vhost.d/siteFolder/web/
<Directory /var/www/vhost.d/siteFolder/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L] ##or app.php for prod mode
</IfModule>
</Directory>
see symfony doc for more info http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
Upvotes: 1
Reputation: 896
There are two default front controller in symfony 2. app.php for production environment and app_dev.php for development environment. All the request route with this front controller.
localhost/Symfony/web/app_dev.php/sample/hello
means you are using development environment.
localhost/Symfony/web/sample/hello
means you are using production environment.
You can add virtual host in httpd-vhosts.conf to change
http://localhost/Symfony/web/
path with your desire path.
Upvotes: 1