Force redirect if a valid taxonomy term is not at the start of the URL?
-
16-10-2019 - |
Question
As a follow on from this question I am trying to prepend all URLs on the site with a taxonomy term.
The term itself is handled by a custom module for the most part, however elements of the site such as the calendar modules page view don't allow for me to intervene and theme the link accordingly. If a user goes to the following URL:
- site.com/calendar
Then they should be redirected to:
- site.com/city/calendar
The city itself would be acquired from a cookie set when they hit the front page of the site, or defaults to 'all-cities'.
My vision for such a system was to check in hook_boot against a predefined array for offending patterns (such as calendar) and if they are found, then it forces a redirect to the same page but prepends the city.
My gut feeling is that this is a bad approach and possibly un-Drupal. Please let me know if there is a standardized method I should be following for such things.
O’ Salvation, Deliver Me From Evil!
Solution
I wouldn't recommend using such system because I also have the gut feeling that this would create some major confusion for modules relying on the drupal path system.
I think you should better deal with subdomains like city.site.com
.