如何删除"网络/ app_dev.php"从Symfony2的网址?网址、网络、QUOT、app_dev

2023-09-02 00:21:20 作者:保护树木゛抵制作业

我刚刚创建我的第一个Symfony2的项目。但在URL中的/web/app_dev.php的一部分让我很烦。它应该能够做到这一点的没有的虚拟主机...

I just created my first Symfony2 project. But the "/web/app_dev.php" part in the URL annoys me. It should be possible to do this without Virtual hosts...

但是当我尝试这样通过的.htaccess我总是得到错误路由和网/总是被添加到URL ......

But when I try this through .htaccess I always get routing errors and the "web/" is always added to the url...

编辑:整个项目也是在一个名为symfonyTest子目录中。的URL演示页为http://localhost/symfonyTest/web/app_dev.php/demo/,它应该成为的http://本地主机/ symfonyTest /演示/。链接也应该有这样的语法。这可能吗?

The whole project is also in a subdirectory named "symfonyTest". The Url to the demo page is "http://localhost/symfonyTest/web/app_dev.php/demo/" and it should become "http://localhost/symfonyTest/demo/". Links should also have this syntax. Is this possible?

推荐答案

Symfony2中带有一个内置的调试模式,这是当你访问的URL与app_dev.php此外,您使用的是什么。调试模式缓存显著不足,可以通过引导浏览器的URL,但留下了app_dev.php访问的生产方式。如果访问该网址不起作用,那么它可能意味着你需要清除您的生产缓存。

Symfony2 comes with a built in debug mode, which is what you are using when you access url's with the app_dev.php addition. The debug mode caches significantly less than the production mode which can be accessed by directing your browser to the url, but leaving out the app_dev.php. If accessing this url doesn't work then it probably means that you need to clear your production cache.

要清除缓存直接,你的终端(命令控制台)到你的根Symfony的项目。从那里键入以下命令:

To clear the cache direct you terminal (command console) to the root of you Symfony project. From there type the following command:

php app/console cache:clear --env=prod --no-debug

这应该清除您制作的缓存,并允许您访问的网址不app_dev.php。

This should clear your productions cache and allow you to access urls without the app_dev.php.

而对于URL的Web部件。除去最简单的方法是将你的项目的Web根目录设置为Web文件夹。这是最好的使用虚拟主机的Apache做到这一点,但有办法与htaccess的做到这一点。

As for the web part of the url. The easiest way to remove that is to set the web root of your project to the web folder. It's best to do this with apache using virtual hosts, but there are ways to do it with the htaccess.

此链接说明了如何使用htaccess的文件来更改Web根目录。 的http://kb.siteground.com/how_to_change_my_document_root_folder_using_an_htaccess_file/

This link explains how to use the htaccess file to change the webroot. http://kb.siteground.com/how_to_change_my_document_root_folder_using_an_htaccess_file/

希望这有助于!

 
精彩推荐
图片推荐