简体   繁体   English

symfony和apache友好的网址

[英]symfony & apache friendly url

I am writing because after searching&reading i still have doubts about if i can make an url like this: (a) http://www.balancextreme.es/tiendaweb/tienda/nuestrosProductos?culture=es 我写作是因为在搜索和阅读后我仍然怀疑我是否可以制作这样的网址:(a) http://www.balancextreme.es/tiendaweb/tienda/nuestrosProductos?culture=es

to show like this in search engines: (b) http://www.balancextreme.es/pulseras-y-zapatillas-famosos.html 在搜索引擎中显示如下:(b) http://www.balancextreme.es/pulseras-y-zapatillas-famosos.html

Doubts involved (and i hope this are usefull for others too!) are: 涉及的疑问(我希望这对其他人也有用!)是:

If i do it in htaccess (rewrite) will (ie google) show this one (even when url_for in the template is the (a) link)? 如果我在htaccess中执行(重写)将(即谷歌)显示这一个(即使模板中的url_for是(a)链接)? Or, if that`s not the case, can i achieve this in the routing.yml? 或者,如果不是这样,我可以在routing.yml中实现这一点吗? (the examples i studied doesnt show this kind of change and i couldnt figure out how to do it) (我研究的例子没有显示出这种变化,我无法弄清楚如何去做)

well, that s it! 好吧,就是这样! Someone can help on this? 有人可以帮忙吗?

thank 谢谢

If you're using Symfony, you should use the Symfony routing system... 如果您使用的是Symfony,则应使用Symfony路由系统...

There you could create a route like this: 你可以在那里创建一个这样的路线:

#/apps/frontend/routing.yml:
show_product:
  url: /product/:slug
  params: { module: products, action: show }

Then, in your view, use <?php echo link_to($product->name, 'show_product', array('slug' => $product->slug); ?> . 然后,在您的视图中,使用<?php echo link_to($product->name, 'show_product', array('slug' => $product->slug); ?>

If you solve your problem with mod_rewrite, which is possible, you miss the flexibility of referring to routes in your frontend. 如果您使用mod_rewrite解决了问题,那么您可能会错过引用前端路由的灵活性。 And if you change an URL, you'll have to manually change all references to that URL. 如果更改URL,则必须手动更改对该URL的所有引用。

But this is the really compact explanation... You should really look into this tutorial, which explains everything very good: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/05 但这是一个非常紧凑的解释......你应该真正研究这个教程,它解释了一切非常好: http//www.symfony-project.org/jobeet/1_4/Doctrine/en/05

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

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