2

I have a site where all the main navigation links (Top Navigation, footer nav and html sitemap page) link to URLs without a trailing slash, however the canonical tags for all pages end with trailing slash.

Is there a way to change all the links in the main navigation to link to pages with a trailing slash, or failing that change SEO lite to define a canonical without a trialing slash?

This is my first time using ExpressionEngine.

3 Answers 3

2

This is an old topic with plenty of useful information that seems to mirror your question. Hopefully this is helpful to you:

https://stackoverflow.com/questions/13213812/getting-the-trailing-slash-back-in-expressionengine-2

1

In general, don't try to force EE to use a trailing slash.

Do the opposite - make the canonical links without a trailing slash.

Seriously, that is the way EE likes it, and you are pushing shit uphill trying to do anything else.

Don't use a 301 htaccess redirect - that's ridiculous, because EE generates all URLs without a trailing slash. Then you would be forcing all of your users to make two requests every time they click a link, just so you can have your way. Not a good idea :)

Best bet is figuring out how to make SEO Lite define a canonical URL without the trailing slash (I've never used it). Or just build the canonical meta tag yourself.

0

There's no way -- that I'm aware of -- to force trailing slashes within EE itself. I would hardcode the trailing slashes into your navigation where possible and failing that use a rewrite rule within your .htaccess file to force it.

RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+[^/])$ /$1/ [R=301,L]

If you're using something like Structure or the Pages module, SEO Lite should use the matching url from the pages array. There's an old support thread that explains the issue and subsequent updates to SEO Lite.

5
  • Any idea which file one might need to edit to make sure all main navigation links with trailing slashes? If it is as easy as just changing a few things in a template?
    – moobot
    Jun 18, 2013 at 7:11
  • When I add a trailing slash to the 'Structure Page URL' under the 'Structure' and submit, it never saves. I go back in and it's without a trailing slash again.
    – moobot
    Jun 18, 2013 at 7:26
  • In the module settings for Structure there's an option to set 'Add Trailing Slash to Page URLs' to yes or no.
    – Dylan
    Jun 18, 2013 at 8:04
  • Right bare with me, maybe I'm being a but dim but i cant find this setting. If i click 'Structure' from the modules menu I get taken to the list of pages. Then top right is a tab 'Module settings', but there is no option for a trailing slash.
    – moobot
    Jun 18, 2013 at 9:59
  • Mm, are you a super admin for the site and what version of EE and Structure are you using?
    – Dylan
    Jun 18, 2013 at 11:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.