Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-01-19 18:30:47

ar
Member
Registered: 2012-03-08
Posts: 30

Let Textpattern accept URLs with trailing slash?

Hi,

I have the URL scheme /title but I can only access the articles when using /section/title.

Textpattern doesn’t show an empty article but “not found” message.

I don’t understand why that is. The txp:article tag should realize that the article is part of the section, even without the URL.

Edited: Rewrite rule adds trailing slash which isn’t supported by default. See below. Still need a solution.

Thank you,

Alex

(Edit: Thread title changed in order to address the problem better.)

Last edited by ar (2021-01-20 20:02:26)

Offline

#2 2021-01-19 21:01:17

etc
Developer
Registered: 2010-11-11
Posts: 4,252
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

Hi, since it seems to work on the official demo site, it’s difficult to say what’s wrong with yours. Are you trying to access articles via /title/ with trailing slash? Are some plugins/redirects interfering?

Offline

#3 2021-01-20 05:29:57

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,589
Website GitHub Twitter

Re: Let Textpattern accept URLs with trailing slash?

Hi Alex, Article URL patterns are now defined in two places.

  • Admin>Preferences>Site
  • Presentation>Sections>[Click on the name of the section].

Can you check if the Article URL pattern in the section in question, is indeed set to /title?


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#4 2021-01-20 19:50:48

ar
Member
Registered: 2012-03-08
Posts: 30

Re: Let Textpattern accept URLs with trailing slash?

Wow, I just tried it with a Textpattern demo site and realized that is indeed not possible to reach the title-only articles with a trailing slash:

https://release-demo.textpattern.co/welcome-to-your-site

vs.

https://release-demo.textpattern.co/welcome-to-your-site/

I do indeed have a .htaccess rewrite rule that adds a trailing slash to all URLs.

I am much relieved to know that this seems to be the problem.

Is there a way to let Textpattern accept the trailing slash?

Thank you very much :-)

Alexander

PS: Not a solution, but a related thread.

PPS: URL scheme /section/title/ seems to work, see for example:

https://release-demo.textpattern.co/artikel/welcome-to-your-site/

???

Last edited by ar (2021-01-20 20:05:55)

Offline

#5 2021-01-20 20:29:35

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 1,817
Website

Re: Let Textpattern accept URLs with trailing slash?

The lack of displaying a title with a trailing “/” is most likley a bug. I often use the slash for various sites and they work just fine. Like this one for e.g.:
https://forum.textpattern.com/viewtopic.php?pid=328263#p328263/


…. texted postive

Offline

#6 2021-01-20 20:37:26

ar
Member
Registered: 2012-03-08
Posts: 30

Re: Let Textpattern accept URLs with trailing slash?

In a way you are right, I think that this cannot be intended behavior as well. However, your example has a number sign in it. After # you can put whatever you want, it won’t (as far as I know) be parsed on the server-side.

Offline

#7 2021-01-20 21:23:01

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 1,817
Website

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328265:

In a way you are right, I think that this cannot be intended behavior as well. However, your example has a number sign in it. After # you can put whatever you want, it won’t (as far as I know) be parsed on the server-side.

this is a Txp site: https://bicilogic.com/article/three-oaks/

see this discussion


…. texted postive

Offline

#8 2021-01-20 21:26:45

ar
Member
Registered: 2012-03-08
Posts: 30

Re: Let Textpattern accept URLs with trailing slash?

That’s exactly what I haved witnessed. I guess /article/ is the section (in your example), and therefore using a trailing slash works. Without section (/title/ only) it doesn’t. So indeed this seems to be a bug.

Last edited by ar (2021-01-20 21:27:45)

Offline

#9 2021-01-20 21:30:10

etc
Developer
Registered: 2010-11-11
Posts: 4,252
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328263:

I do indeed have a .htaccess rewrite rule that adds a trailing slash to all URLs.

For what purpose?

Is there a way to let Textpattern accept the trailing slash?

It does, but you certainly mean ‘for individual articles’? What would be sections URLs in title_only mode?

PPS: URL scheme /section/title/ seems to work, see for example:

Yes, because there is no ambiguity between /section/ and /section/title/ URLs.

Offline

#10 2021-01-20 21:49:46

ar
Member
Registered: 2012-03-08
Posts: 30

Re: Let Textpattern accept URLs with trailing slash?

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

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, only implicit (if at all) in order to use specific colors for headlines for each “section” (via body class=”<txp:section />”). But that is nothing a visitor should be bothered with. <txp:article /> knows the section, as well as forms and pages, so I don’t see a problem there.

That is my example: (…)

Right know I have to use the section. Since I deleted my (too) many sections yesterday and only have two right now (psychotherapie, impressum) I hand over the different h1 colors (headlines) via categories right now.

However, I only want one section, in fact, because it’s a hassle to create and manage them. I just want to create an article and assign a color. Then manually link to it.

Therefore I would like to remove the sections in the URL scheme because the website is small enough to keep track of the article’s custom url’s.

Last edited by ar (2021-01-20 23:13:28)

Offline

#11 2021-01-20 21:58:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,216
Website GitHub

Re: Let Textpattern accept URLs with trailing slash?

ar wrote #328270:

The purpose is consistency

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


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

#12 2021-01-20 22:01:54

ar
Member
Registered: 2012-03-08
Posts: 30

Re: Let Textpattern accept URLs with trailing slash?

Further details:

My .htaccess:

RewriteRule ^!([^/\.]+)/?$ https://xxx.de/?id=$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^xxx\.de$
RewriteRule ^(.*)$ https://xxx.de/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [R=301,L]

My sections:

default, front page, imprint, psychotherapy

My default form:

<h1 class=”<txp:category1 />”><txp:title /></h1>
<txp:body />

My default page:

<txp:if_section name=“default”>
<txp:article id=“2” form=“default” status=“4” />
<txp:else />
<txp:if_article_list>
<txp:if_section name=“psychotherapie”><txp:article_custom category=“overview” section=“psychotherapie” form=“default” sort=“Posted desc” status=“4” /></txp:if_section>
<txp:if_section name=“impressum”><txp:article_custom category=“overview” section=“impressum” form=“default” sort=“Posted desc” status=“4” /></txp:if_section>
<txp:else />
<txp:article form=“default” status=“4” />
</txp:if_article_list>
</txp:if_section>

Last edited by ar (2021-01-20 23:14:10)

Offline

Board footer

Powered by FluxBB