简体   繁体   English

Symfony-URL中需要app.php

[英]Symfony - app.php required in URL

I recently deployed a symfony project and noticed that the only way I can currently access the project is using the following URL: 我最近部署了一个symfony项目,并注意到当前可以访问该项目的唯一方法是使用以下URL:

http://domain.com/app.php/index

I was wondering if there is a way to automatically get the app.php to be served without actually including it in the URL. 我想知道是否有一种方法可以自动获取app.php而不将其实际包含在URL中。

Something like: 就像是:

http://domain.com/index

Not sure if htaccess is required for this or if this is something that can be accomplished directly using Symfony. 不知道是否需要htaccess或是否可以使用Symfony直接完成。

This is what my htaccess currently looks like: 这是我的htaccess当前的样子:

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

I appreciate any advice, thanks in advance! 我感谢任何建议,在此先感谢!

This is (effectively) the .htaccess file which I use on several projects and sites using Symfony 2: 这是(有效地) .htaccess文件,我在使用Symfony 2的多个项目和站点上使用了该文件:

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

I also have the following vhost entry for one of my Symfony projects under the apache server: 对于apache服务器下的我的一个Symfony项目,我还具有以下vhost条目:

<VirtualHost *> ServerAdmin admin@localhost DocumentRoot "<PATH_TO_PROJECT>/web" ServerName localhost ServerAlias localhost ErrorLog "<PATH_TO_PROJECT>/app/logs/apache_error.log" ErrorLogFormat "[%t] [%l] [pid %P] thread-%T %F: %E: [client %a] %M" <Directory "<PATH_TO_PROJECT>/web"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost>

The omission of the DirectoryIndex app.php index may be enough in the .htaccess file, so you could try that. .htaccess文件中,省略DirectoryIndex app.php索引可能就足够了,因此您可以尝试这样做。 Admittedly my knowledge of Apache configuration is weaker than I would like it to be, hopefully this helps, if not--hopefully some one out there can give you a better, stronger answer? 诚然,我对Apache配置的了解比我希望的要弱,如果没有的话,希望对您有所帮助-希望那里的人能给您一个更好,更强大的答案?

Best of luck! 祝你好运!

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

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