.htaccess - 交响乐2 : How to remove the "/web/" folder from the url in a shared hosting?

标签 .htaccess mod-rewrite symfony url-rewriting

我一直在寻找一种方法来从共享环境中的应用程序 URL 中删除“/web/”文件夹,在该环境中我无法更改 DocumentRoot 或创建 VirtualHost。

我找到了一些基于 mod_rewrite 的解决方案,但它们都适用于 Symfony 1.x,或者它们根本不起作用(无论如何,我对 mod_rewrite 很陌生,所以这可能是我的错)。

有办法用 Symfony 2 做到这一点吗?

最佳答案

您必须将 Web 服务器的文档根目录设置为指向您的“Web”目录。如果您无法自定义文档根目录,只需将“web”目录的内容直接移至文档根目录,并将所有其他人员移至上一级。例如:

/home/username/www/html <---- this is the place where you put all things from "web"
/home/username/www/src  <---- and all other things one level above
/home/username/www/app
/home/username/www/vendor
...

关于.htaccess - 交响乐2 : How to remove the "/web/" folder from the url in a shared hosting?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11929435/

相关文章:

symfony - 如何将依赖项注入(inject) Symfony 控制台命令?

regex - apache .htaccess 重写不应包含 www

angularjs - 使用 Html5Mode 刷新页面时出现意外 token

.htaccess - htaccess SEO 网址

forms - Symfony:调用表单 handleRequest 但避免实体持久化

php - Symfony Controller - 如何返回 XML 响应?

php - 如何通过 .htaccess 创建动态目录和子目录

php - 将所有 WordPress 帖子和页面重定向到主页

regex - RewriteCond 排除不工作的路径

.htaccess 重写电子邮件/ token 规则