Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: 12,494
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.

Hire Txp Builders – finely-crafted code, design and Txp

Online

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,494
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.

Hire Txp Builders – finely-crafted code, design and Txp

Online

#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: 5,217
Website GitHub

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,689
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,689
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

#25 2021-01-20 22:52:38

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

Re: Let Textpattern accept URLs with trailing slash?

Ok but how do I “internally remove” trailing slashes? Are you referring to mod_rewrite or are you recommending to use the /title URL scheme and refrain from using trailing slashes when linking to individual articles?

Offline

#26 2021-01-20 22:55:53

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

Re: Let Textpattern accept URLs with trailing slash?

Do I understand correctly: No longer use R=301 in mod_rewrite in order to not change the address bar, learn how to remove trailing slashes in mod_rewrite (“internally”), and use canonical links in order to prevent getting the content rated as duplicate (because we are no longer using R=301)?

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

Offline

#27 2021-01-20 22:59:45

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

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328287:

Ok but how do I “internally remove” trailing slashes?

With something like

RewriteRule ^(.*)/$ /$1 [L]

but many sites explain it much better than me.

Are you referring to mod_rewrite or are you recommending to use the /title URL scheme and refrain from using trailing slashes when linking to individual articles?

Both should work, just remove the slash-adding rule from your .htaccess to try.

Offline

#28 2021-01-20 23:01:29

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

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328288:

Do I understand correctly: No longer use R=301 in mod_rewrite in order to not change the address bar, learn how to remove trailing slashes in mod_rewrite (“internally”), and use canonical links in order to prevent getting the content rated as duplicate (because we are no longer using R=301)?

Quite right imo, but I may be wrong.

Offline

#29 2021-01-20 23:12:58

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

Re: Let Textpattern accept URLs with trailing slash?

Thank you very much, I will try it out. :-)

Offline

#30 2021-01-21 07:09:42

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,394
Website GitHub Mastodon Twitter

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328282:

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)

Check github.com/colak/neme/blob/master/pages/about.tpl#L200 and github.com/colak/neme/blob/master/forms/search_results.tpl#L5

  • Deliver specific articles as “landing page” by assigning a “landingpage”-category (in my example called “overview”) when URL is /section

github.com/colak/neme/blob/master/pages/projects.tpl#L204

  • Deliver everything else as regular articles but have the need to use /section/article URL.

If you have the section/category/title url pattern, this will not be possible, but it is possible if you use the section/title one.

There was a big discussion some time ago about how these url patterns should work. In my view, if you use categories, they should be reflected in the site’s tree so

  • /products/
  • /products/paints/
  • /products/paints/acrylic

makes a semantic sense but

  • /products/acrylic

does not as acrylic could refer to something which might not be a paint.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB