0
votes

I have a problem with generating relative URL in symfony 2.7 project

My project is hosted behind a proxy that redirect URL to the target VM, like this - example.com/oblounge/bo/ to vmhostname/

All my URL are generated in relative

Here is my problem

For example when I'm on this page

http://example.com/oblounge/bo/admin/articles/actualite?section=127

All generated likns are malformated, the "/admin/articles" is duplicated

http://example.com/oblounge/bo/admin/articles/admin/articles/actualite?section=127

Note: The problem is occurred only for rendered controllers

The render action

{{ render(controller('AppBundle:Back/Article/Article:sectionsArticle', { 'rubric': 'actualite' })) }}

The rendered twig

{% for section in sections %}
    <li><a href="{{ path('back_post_list', {'rubric': 'actualite'}) }}?section={{ section.iden }}"><i class="fa fa-circle-o"></i>{{ section.name }}</a></li>
{% endfor %}

My routing.yml

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

The prefix of my admin controller

/**
*  @Route("/admin")
*/

class ArticleController extends BaseArticleController
{
1

1 Answers

0
votes

I would suggest you give a look at your routing.yml file that is referenced within your bundle. If you've already defined a prefix for the route in the routing.yml of you app/config there is no need to repeat it in the routing of your bundle , otherwise there will be a duplication of prefixes as in your case.

Example:
This is the routing.yml in the App\config folder

tutoLexikTestBundle_parents:
    resource: "@tutoLexikTestBundle/Resources/config/routing/parents.yml"
    prefix:   /parents

And this is the one of the bundle

parents_show:
    path:     /{id}/show
    defaults: { _controller: "tutoLexikTestBundle:Parents:show" }

I don't need to repeat the prefix 'Parents' in the path