[英]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. 我正在尝试在远程服务器上安装本地symfony应用程序。 The application is currently installed in a public directory.
该应用程序当前安装在公共目录中。 So I can access my app with
www.mysite.com/public/web
因此,我可以通过
www.mysite.com/public/web
访问我的应用
To get rid off the public/web
part, I created a .htaccess
in the server root with the following : 为了摆脱
public/web
部分,我在服务器根目录中使用以下命令创建了一个.htaccess
:
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 ! 现在,我可以访问
www.mysite.com
,一切正常! But, all the link and the assets have kept the public/web
part. 但是,所有链接和资产都保留了
public/web
部分。
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. 可能存在带有
twig
功能path
和asset
的配置,但是我找不到它。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.