简体   繁体   English

symfony路由问题

[英]symfony routing problems

I'm building a site using symfony php framework. 我正在使用symfony php框架构建站点。

I have a link in my page which leads to page X : 我的页面上有一个链接,该链接指向第X页:

<a href="/X">test</a>

well, the problem is, under my development environment, the link works and the link points to 好吧,问题是,在我的开发环境下,该链接有效,并且链接指向

http://localhost/web/frontend_dev.php/X http://localhost/web/frontend_dev.php/X

but when Im using the production page (index.php) the link turns out to point to : 但是当我使用生产页面(index.php)时,该链接指向:

http://localhost/web/X http:// localhost / web / X

when it should point to : 什么时候应该指向:

http://localhost/index.php/X http://localhost/index.php/X

any ideas what the problem is ? 任何想法是什么问题?

thanks! 谢谢!

Every link in symfony template should be generated by helper link_to() or url_for(): http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer symfony模板中的每个链接都应由助手link_to()或url_for()生成: http : //www.symfony-project.org/book/1_2/07-Inside-the-View-Layer

frontend_dev.php - is a development version of the front controller. frontend_dev.php-是前端控制器的开发版本。 If you are accessing a page via this controller ( http://localhost/frontend_dev.php/testmodule/testaction ), all links will be processed by this controller. 如果您正在通过此控制器( http://localhost/frontend_dev.php/testmodule/testaction )访问页面,则所有链接都将由此控制器处理。 If you will call your site via production controller (index.php, the default one), all links will point via it: ( http://localhost/testmodule/testaction ): http://www.symfony-project.org/book/1_2/06-Inside-the-Controller-Layer 如果您将通过生产控制器(默认的index.php)调用站点,则所有链接都将通过它指向:( http:// localhost / testmodule / testaction ): http : //www.symfony-project.org/ book / 1_2 / 06-控制器内部层

Also, you have incorrect site layout. 另外,您的网站布局不正确。 You shouldn't have any "web" subfolder in the site. 您的网站中不应包含任何“网络”子文件夹。 Symfony libraries should be put into non-accessible area by browser. Symfony库应被浏览器放置在不可访问的区域。 You should reread symfony documentation once more. 您应该再次阅读symfony文档。 And study this learning-project: http://www.symfony-project.org/jobeet/1_2/Doctrine/en/ 并研究这个学习项目: http : //www.symfony-project.org/jobeet/1_2/Doctrine/zh/

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

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