Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2021-01-20 22:02:40

ar
Member
From: Nuremberg, Germany
Registered: 2012-03-08
Posts: 45
Website

Re: Let Textpattern accept URLs with trailing slash?

Bloke wrote #328271:

It already is consistent. If a URL represents an article it has no trailing slash. If it represents a landing page, it has one.

What do you mean by landing page?

That doesn’t solve my problem, however :-(

Offline

#14 2021-01-20 22:03:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328270:

I don’t need sections in a “public” way, only implicit (if at all) in order to use specific colors for headlines for each “section”

Fine, but your use case isn’t the only use case in Textpattern. We need to cater for other people that do require sections in the URL schemes too. We provide many schemes to let people choose how they want each section to behave. And a fallback scheme in prefs.

Without that telltale trailing slash, we have no way of knowing (without trial and error, which is computationally a little more expensive and therefore slower) whether /products is an article called ‘products’ in a section, or the section landing page for /products.

If you have both in your site, which should Textpattern choose when faced with that URL?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2021-01-20 22:05:55

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328270:

The purpose is consistency: I redirect all http to https, all www to non-www, and adding trailing slashes when they’re not there.

There is a difference between rewrite and redirect. You should be able to redirect browsers to slashed URLs, but then rewrite /title/ as /title to make txp understand that it is not a section.

Why should there be no ambiguity when /title (without trailing slash) has the same name as /section? I don’t need sections in a “public” way

You don’t, but other users do. How would they tell /about/ section from /about/ article if both exist?

This said, I agree txp URL schemes are not flexible enough and we should introduce custom schemes one day.

Offline

#16 2021-01-20 22:05:58

ar
Member
From: Nuremberg, Germany
Registered: 2012-03-08
Posts: 45
Website

Re: Let Textpattern accept URLs with trailing slash?

Bloke wrote #328274:

If you have both in your site, which should Textpattern choose when faced with that URL?

Isn’t there a warning if I want to use a custom url that has the same title as a section?

Offline

#17 2021-01-20 22:06:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328273:

What do you mean by landing page?

An article list. A category list. An author list. An image list. A tag list. etc

That doesn’t solve my problem, however :-(

No, but we might be able to find a way round it or make some changes if we know why the distinction of article = no trailing slash and list = trailing slash isn’t consistent enough for Textpattern as a whole, and your users specifically.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#18 2021-01-20 22:12:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328276:

Isn’t there a warning if I want to use a custom url that has the same title as a section?

Nope. The URL schemes aren’t (yet) flexible enough, as etc says. One day.

But even then, what happens if you write an article called ‘products’ when you have a few sections, then later introduce a /products section? Or rename an existing section to that name? Will Textpattern have to go through and check every article’s URL-only title to see if it matches the section name you’ve just created/altered? That’s a BIG burden when you save changes.

You do get a warning if you try to make two articles with the same name and you may then need to manually alter their URL-only title, unless you specifically want this feature. We don’t forbid it, just in case, but if you try to access one of the URLs without its section, Textpattern will barf with (I think) a 404.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2021-01-20 22:17:36

ar
Member
From: Nuremberg, Germany
Registered: 2012-03-08
Posts: 45
Website

Re: Let Textpattern accept URLs with trailing slash?

etc wrote #328275:

You should be able to redirect browsers to slashed URLs, but then rewrite /title/ as /title to make txp understand that it is not a section.

Is that my solution? Put another way: Will I (and search engines) notice the rewriting because the slash gets cancelled in the browser bar (in general)? Or can I “hide” the rewriting (keeping the slash, cancelling it only internally)?

However, even if that is possible (I am not really familiar with mod_rewrite), then I still imagine that Textpattern wouldn’t know whether it is a section or an article that is being requested.

What if I have no rewriting in place but an article and a section with the same name? Will /name deliver the article and /name/ deliver the section?

Last edited by ar (2021-01-20 22:19:29)

Offline

#20 2021-01-20 22:25:42

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: Let Textpattern accept URLs with trailing slash?

I guess it’s a product of Textpattern’s ability to always interpret /section/title url schemes even when the url scheme is set to something else. Therefore, in this particular Textpattern recognises:

https://www.mysite.com/article-url-title

as an article, and

https://www.mysite.com/article-url-title/

as a section, and as there is no article-url behind it, shows the landing page (article_list) view.


TXP Builders – finely-crafted code, design and txp

Offline

#21 2021-01-20 22:29:34

ar
Member
From: Nuremberg, Germany
Registered: 2012-03-08
Posts: 45
Website

Re: Let Textpattern accept URLs with trailing slash?

Ok I guess that my “messy” page code is the best I can do in this case:

  • Deliver a specific ID as front page article (in my example id=2)
  • Deliver specific articles as “landing page” by assigning a “landingpage”-category (in my example called “overview”) when URL is /section
  • Deliver everything else as regular articles but have the need to use /section/article URL.

If there really is no workaround right now I still want to thank you all! I am using Textpattern for so many years now and I really appreciate the work put into it. :-)

Last edited by ar (2021-01-20 22:33:48)

Offline

#22 2021-01-20 22:34:47

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328280:

Will I (and search engines) notice the rewriting because the slash gets cancelled in the browser bar (in general)? Or can I “hide” the rewriting (keeping the slash, cancelling it only internally)?

As I get it, no one (but txp) will notice anything if you rewrite but not redirect.

However, even if that is possible (I am not really familiar with mod_rewrite), then I still imagine that Textpattern wouldn’t know whether it is a section or an article that is being requested.

What if I have no rewriting in place but an article and a section with the same name? Will /name deliver the article and /name/ deliver the section?

Yes, for txp in title_only mode /about/ is a section and /about is an article, be it rewritten or not. So if you don’t want your sections be accessible, you should remove (internally) trailing / from URLs.

Actually, I think you could use canonical links (either with or without trailing slash) instead of redirects.

Offline

#23 2021-01-20 22:37:21

ar
Member
From: Nuremberg, Germany
Registered: 2012-03-08
Posts: 45
Website

Re: Let Textpattern accept URLs with trailing slash?

etc wrote #328283:

(…)

Thank you, I guess I have to meditate some serious amount of time over this, because I don’t really get what I would have to do now. :-)))

Last edited by ar (2021-01-20 22:38:28)

Offline

#24 2021-01-20 22:43:46

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

If you internally remove trailing slashes and put

<link rel="canonical" href="https://path/to/title/" />

in the <head /> of you page, then SE will consider https://path/to/title, http://path/to/title/ etc (that all lead to title article) as the same page. In theory :-)

Offline

Board footer

Powered by FluxBB