We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Any way to use trailing slashes with {redirect}?

How Do I?

James Catt's avatar
James Catt
17 posts
8 years ago
James Catt's avatar James Catt

I have a redirect in one of my templates like so:

{redirect="path/to/template/{url_title}/"}

It works for the most part, except for one problem: EE is stripping the trailing slash. I have Apache configured to enforce trailing slashes for SEO/Analytics purposes, so when people hit this template they’re getting a double redirect (once from EE to the new URL path, then a second time from Apache enforcing the trailing slash).

Is there no way to get ExpressionEngine to stop stripping the slash from my redirect path? I can always redo the redirect in PHP, but I’d prefer not to.

       
James Mathias's avatar
James Mathias
225 posts
8 years ago
James Mathias's avatar James Mathias

There isn’t a way to prevent trailing slashes from being stripped from the redirect variable.

We strip it, because a trailing slash indicates a “directory” and ExpressionEngine doesn’t use directories for it’s URLs. Keep in mind that in general / vs no-/ isn’t a big deal, so long as you are consistent on your site, and don’t allow a URL to be served in both ways.

       
energycell's avatar
energycell
18 posts
6 years ago
energycell's avatar energycell

May be too late for the OP, but in case anyone else needs this:

There is a way to maintain trailing slashes, just add a trailing space after the ‘/’.

       
James Catt's avatar
James Catt
17 posts
6 years ago
James Catt's avatar James Catt

Thanks energycell! I’ve already switched to PHP redirects, but that’s good to know.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.