Search

Latest Symphony releases do not need several .htaccess files anymore, which is great. But I do not really see the advantage of omitting the trailing slash rule. This rule has ever been there in older versions:

### CHECK FOR TRAILING SLASH - Will ignore files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]

I had some problems on a website which used relative links from time to time. If the trailing slash in the URL is missing, the relative link will mean something different…

Of course you could add this rule manually. But the problem I see here that it must be added behind the image rules, which means in the “Symphony - do not edit” part of the .htaccess file.

Will this rule eventually return?

michael-e, to clarify — are you saying that Symphony no longer enforces a trailing slash on requests? So if I were to navigate to the following:

http://domain.com/about

I would not then be redirected to:

http://domain.com/about/

I know the above used to be the case, so are you saying that this has been removed?

Yes, this has been removed in 2.0.6. Symphony no longer enforces a trailing slash on requests.

I do not know why (nor have I read anything about it in the README or in the forum).

It would be very useful to know the roadmap.

Personally, I think excluding the trailing slash produces cleaner URLs. So long as your RewriteRules are setup correctly, there should be little (if any) performance penalty for doing this - I don’t follow how relativity of links would be affected by this change. I could see problems if both

http://domain.com/about

and

http://domain.com/about/

responded as if they were two different documents (duplication of content). Have you got an example of where this doesn’t work for you?

If you simply do a default installation of Symphony 2.0.6, you will see that at the moment both URLs will work.

Now try a relative link like <a href="me/">Learn about me</a>.

If you are on

http://domain.com/about/

your link points to this URL:

http://domain.com/about/me/

But if you are on

http://domain.com/about

you will end up here:

http://domain.com/me/

Personally, I think excluding the trailing slash produces cleaner URLs.

I’m with you.

@michael-e In this case I suggest you to use the base tag. I’m not favor of using relative urls.

@rainerborene: I know that relative URLs are not always ideal. My point is s.th. different: Simply removing the mentioned rule from the .htaccess file in Symphony 2.0.6 can break things on existing websites. Therefore I tried to find out if the rule was left out intentionally or if I should file a bug report.

Well, the discussion going on here shows me that there should definitely be a bug report, because nobody knows about this new “feature”.

Personally, I think excluding the trailing slash produces cleaner URLs.

No, I don’t think so. Trailing slashes are much more logical, unless you request a file (having a file extension). Have you ever seen Apache deliver http://www.anydomain.com/ without a trailing slash?

I posted a bug report.

@michael-e I don’t think that’s a bug. Both ways are correct.

Although both ways are technically correct I think behaviour should remain consistent, even if it means supporting legacy sites. I can think of several sites where I use relative links which rely on the trailing slash. If a user were to arrive at the page without the trailing slash then these links would be broken.

Personally, I think excluding the trailing slash produces cleaner URLs.

As shortcut vanity URLs they work (e.g. http://domain.com/my-alias which then redirects to a deeper page) but I’ve always thought the opposite in terms of cleanliness!

@rainerborene: Dropping the rule without having changed the desired feature is a bug. And indeed nobody (not even nickdunn) seems to know about a feature change for the trailing slash rule. (Maybe Alistair knows, but then he can simply explain his intention and close the bug.)

:-)

Thanks for adding the discussion link to the bug tracker.

Well, you may discuss the feature. But please keep in mind that without any “trailing rule” your website allows for duplicate content (content having two URLs). I heard that search engines may not like this. So we should probably have a “trailing rule”.

@Michae-e: It is certainly bad form to offer two URLs to point to the same content.

This should be classified as a bug.

I should explain how this came about:

Alistair and I spoke about the possibility of offering different options for enforcing the URL structure, trailing slash v.s. non trailing slash. This discussion arose due to the difference in opinion about which method is preferable – much like the opinions made here. During the onslaught of updates to the installer, .htaccess and index.php updates and cleanup, this “feature” snuck its way in – I believe the feature was still being deliberated and Alistair made the change locally as a quick proof-of-concept. As the development went on, this piece of code remained.

The intention is to provide options for either trailing slash or non-trailing slash, but no option for both.

Thanks, Allen.

You can’t say fairer than that - thanks Allen. My personal preference is for a slash… which side of the fence are you on?

I think this is a great approach, Allen. This is exactly what I proposed for Textpattern back in 2006, but all I got was a somewhat snitty reply from the developer. Of course, that thread contributed to my decision to leave txp, which led me to Symphony — so maybe I should thank Sencer…

Personally, I think excluding the trailing slash produces cleaner URLs.

I don’t think so. For example: You have a blog on /blog/ and your articles in /blog/article/title/.

Leaving out the trailing slash would result in /blog not being a (virtual) directory but a file, thus “being not allowed to contain additional pages”.

This means by clicking on an article-link you would not descend into /blog but switch to /blog/ and then start descending.

Seems like providing the option is clearly the way forward ;)

I agree that it should be an optional thing. There are 2 ways to achieve it:

  1. Modification of the .htaccess
  2. Handled in Symphony via PHP using a setting in the config (on|off)

The problem with #2 is that PHP needs to be invoked, where as #1 would not. Not great if, say for instance, Dig links to your site via a URL with no trailing slash and PHP has to keep redirecting. You can set a 301 permanent redirection header I guess. I still think it is better suited to a .htaccess rule.

With regards to #1, I am not a fan of modifying the .htaccess automatically with PHP. Seems too magical for my liking and also potentially error prone. So, after chatting with Allen, we feel the best option is to have an advanced setting in the installer for setting the desired behaviour. Something along the lines of “Automatically add trailing slashes to URLs” or “Do not require trailing slashes on URLs”. The default, I am not sure which, but that’s a minor point. For those that set it one way, but then want to change it, we’ll make sure there is a tutorial or mention in the README about how to do it.

You could always include the trailing slash rules in the .htaccess and comment it out depending on preference. That way it’s easy to fix down the track if you change your mind.

Good idea.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details