1

I want these two dynamic routes to pass from the single controller https://www.example.com/Andersonville_apartments.html https://www.example.com/Albany_Park_apartments.html

and the route in controller which i have called is this

@Route("/{id}_apartments.html", name="neighborhood_detail")

Now the problem is this that it detect the First URL with single underscore but doesn't detect the second one with two Underscore as controller doesnot detect the route . Can Any one help me to do this PS: I cannot remove the underscore and replace it with the / as its the requirement .

1 Answer 1

1

You should add requirements parameter to your route definition to allow underscores. Something like this :

@Route("/{id}_apartments.html", name="neighborhood_detail"), requirements={"id"="[a-zA-Z0-9_]+"})

Hope this help you

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks man it work only one small issue you have to remove the closing brakets from the neighborhood and it work perfect then

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.