Jump to content

Make one whitelisted URL segment work without ending slash when all the others end with slashes


Recommended Posts

Posted

Good day!

One of my templates has a list of allowed (whitelisted) url segments set (via "Which URL Segments do you want to allow?") . And all of them but one should end with a trailing slash for SEO reasons. The new url segment (called `sitemap.xml`) should work without trailing slash. Could you please suggest how this could be done?

Posted

Untested... and just a starter idea for your use case, but maybe via a hook in site/ready?

if ($input->urlSegments->count > 0 && $input->urlSegment(1) === 'sitemap.xml) {
rtrim($input->urlSegmentStr() '/');
};

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...