简体   繁体   English

如何在Symfony2中使用.htaccess删除/ web?

[英]How to remove /web using .htaccess in Symfony2?

I have deployed a Symfony application to my production server. 我已经在我的生产服务器上部署了一个Symfony应用程序。 Now I need to remove /web from the domain name, and I have searched for different solutions for this. 现在,我需要从域名中删除/ web,并且已经为此寻找了不同的解决方案。 For example I tried this , but it only resulted in a 500 error. 例如,我尝试过此方法 ,但仅导致500错误。 I have read the answers of many similar questions, but I can´t find a solution that works. 我已经阅读了许多类似问题的答案,但找不到有效的解决方案。 Could anyone give me a clue? 谁能给我一个线索?

This is my htaccess-file: 这是我的htaccess文件:

DirectoryIndex app.php

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mydomain.se$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.mydomain.se$
    RewriteCond %{REQUEST_URI} !folder/
    RewriteRule (.*) /web/$1 [L]

</IfModule>
    <IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>       
    RedirectMatch 302 ^/$ /app.php/       
</IfModule>

This is what works for me 这对我有用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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