简体   繁体   中英

Proper way to remove web directory from the path twig function in the url

I'm trying to install my local symfony application on a remote server. The application is currently installed in a public directory. So I can access my app with www.mysite.com/public/web

To get rid off the public/web part, I created a .htaccess in the server root with the following :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteCond %{REQUEST_URI} !public/web/
RewriteRule (.*) /public/web/$1 [L]

Now, I can access with www.mysite.com and it's work fine ! But, all the link and the assets have kept the public/web part.

It works, but I want to remove this part.

There is probably a configuration with the twig function path and asset , but I can't find it. Any idea ?

Thanks.

Change your document root.

My vhost config looks like this

<VirtualHost *:80>
  ServerName mysite.com
  DocumentRoot /full/path/to/public/web/symfony-project/web
  DirectoryIndex app.php
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM