1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How should Xen URL's end?

Discussion in 'XenForo Questions and Support' started by Wootalyzer, Mar 26, 2011.

  1. Wootalyzer

    Wootalyzer Active Member

    It's a question that's been bugging me constantly, but the answer probably doesn't even matter. Regardless --

    Should XenForo URL's end with a slash? You may notice that some links are built with a ending slash (such as http://xenforo.com/community/members/), and some are built without (such as http://xenforo.com/community/account/contact-details). In either case, you can still add or remove the trailing slash, and the URL will continue to work (without redirecting you to one or the other).

    Is it the standard to only use a ending slash after the major slug, but not after any following slugs? In that case, why do threads have a slash at the end? And why does the built in canonical redirect not force it one way or another?

    ... and yes, I'm being picky.
    Despair likes this.
  2. Kier

    Kier XenForo Developer Staff Member

    The use of the trailing slash actually controls functionality in some cases with XenForo. For example:

  3. Wootalyzer

    Wootalyzer Active Member

    I suppose that makes sense -- so actions basically terminate the slug path (because logically nothing would follow them), but things like ID's and site sections terminate with a / because they basically act as a directory (for the "actions" that they contain).

    In other news, while I'm on a roll of random SEO chatter, I noticed that
    http://xenforo.com/community/?members&othervariables actually passes through the /members route prefix. Is this by design?

    Strike that -- this is used for people with friendly url's turned off. I feel silly. XenForo is awesome!
  4. Despair

    Despair Active Member

    I was about to make this same thread before, but I figured it would be something picky that no one cared about. :)

    You can type: http://xenforo.com/community/members/ with and without the slash, but the one without the slash doesn't 301 to the one with the slash. There is a canonical for the one with the slash however. It would be nice if the non slash 301ed to the one with the slash, or rather redirect to the canonical URL in all cases. But I guess the point of the canonical is so you wouldn't have to do that? Personally I prefer that if the URL is meant to have a slash, it is 301ed to the one with the slash if no slash was used, it just feels more consistent that way, but I think this might be a case where it hurts to be too picky. :whistle:

    Not 100% sure, but this may work for apache equivalent:
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
        RewriteRule ^([^/]*)$ /$1/ [R=301,L]
  5. Wootalyzer

    Wootalyzer Active Member

    I've got a permanent redirect setup in my nginx config which just throws a / on the end of any first-level links without an ending /.
    rewrite ^(/[^/]+)$ $1/ permanent;

Share This Page