2

I am facing a problem while creating applications using Symfony which is the occurrence of '/web' in the url. I found a way to get rid of this by moving the content of 'web' directory to root directory. But I think that is not a good development practice and there must be some other way. Can anyone let me know if there is some other way of doing this some thing like we do for removing app_dev.php from url using htaccess ?

5 Answers 5

3

In my case im working with wamp server and to get rid of "/web" you need to configure a virtual host in httpd-vhosts.conf like this :

<VirtualHost *:80>
    DocumentRoot C:\wamp\www\YourProjectFolder\web
    ServerName projectName.local
</VirtualHost>

I think you shoold do the same in your host server.

Sign up to request clarification or add additional context in comments.

Comments

2

If you don't have the possibility to edit http.conf and mod_rewrite is enabled, simply place a .htaccess file in your Document root and redirect every request to the /web folder.

RewriteEngine on
RewriteRule ^(.*)$ /web/$1 [L,QSA]

1 Comment

This is how I am doing it. In shared hosting this seems to be the only solution
1

Do not move /web folder from Symfony. You just need point your vhost or Apache default root into your web directory. For example :

You can changing in httpd.conf :

# ...
DocumentRoot "your_symfony_folder/web"
<Directory "your_symfony_folder/web">
# ...

2 Comments

Or if you are using Nginx: server { root your_symfony_folder/web; }
Yes, depends to his Apache Server.
0

You can create a .htaccess into project root folder(where is the folder like app, bin, src...):

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

Comments

-2

I think you guys are sweating it.

Correct me if I am wrong, but I managed to remove it by simply putting everything in the web directory inside the root directory. Then I eliminated app_dev.php, and renamed app.php into index.php.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.