We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Remove part of the url?
I'm using this branched setup for a multi-language site
- Home En (/en) - Page1 En (/en/page1) - Page2 En (/en/page2) - Home Es (/es) - Page1 Es (/es/page1) - Page2 Es (/es/page2)
I have a variable
$nav_group that uses the
es part of the URL to change the
navgroup depending on where the user is on the website.
$page_url = perch_page_url(['include-domain' => false,], true); // Output the URL of the current page, minus http $url_parts = explode("/", $page_url); // Split a string by a string $nav_group = $url_parts; // Output the first part of string PerchSystem::set_var('lang', $nav_group); // Set 'lang' for use in html templates perch_pages_navigation(['navgroup'=> $nav_group]); // Output navgroup based on value of $nav_group // print $nav_group; // Test output value of $nav_group
However, The default language is English. The url would look cleaner if I could hide the
en from the url. But, keep the
es and any future languages that might be added.
- Is there a 'Perch way' of removing the
enfrom the url, without changing the tree structure within Perch Admin?
- Or is this a task better suited for a rewrite rule in
Any advice would be greatly appreciated.
Want to reply to this thread?Login with Perch