【发布时间】:2018-12-22 11:22:24
【问题描述】:
我的 /var/www/html/app/ 中有一个 symfony 应用程序,我想通过 host/app/ 访问它,但我无法让它工作。
I have a conf file with this
<Directory /var/www/html/app>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
</Directory>
评论是因为我尝试在此处进行重定向,但没有成功,因此我制作了以下 .htaccess。
还有/var/www/html/app/.htaccess中的这个htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
有了这个 .htaccess,当我转到 ://host/app 时,我会转到 symfony 应用程序(不是 apache 目录结构),这似乎是一个好的开始。
但问题是我得到了一个异常No Routes found for /app/。
这很正常,因为/app/ 是我服务器中的子文件夹,而不是 symfony 路由的开始。
如何使 symfony 路由从 /app/ 文件夹路径开始?
我知道在子文件夹中有一些关于 symfony2/3 路由的问题,但答案需要将 src 和 public 文件分开,这不是我想要的。
我只希望我的路由在访问 ://host/app 时能够正常工作。
有关信息,当我访问 ://host/app/public/*Symfony routes* 时效果很好
编辑:
新app.conf
别名 /rapp "/var/www/html/app/public"
<Directory /var/www/html/app>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!public/index.php)$ public/index.php$1 [L]
</IfModule>
</Directory>
【问题讨论】:
标签: .htaccess symfony mod-rewrite