XF 2.1 404 Page not found on lots of links after migration. Leading and trailing slashes needed.

Stuart Wright

Well-known member
So we had a whole bunch of internal links to pages like
href="pages/privacy-policy/"
which are broken with XF2. They need a leading slash
href="/pages/privacy-policy/"
or they 404 page not found.
Is this a Xenforo 2 thing? A setting somewhere?
I think it might be causing a whole bunch of issues because we're getting lots of junk URLs reported in the 404 log.
E.g.
Code:
https://www.avforums.com/threads/alloy-repair.318860/review/sony-kd-65a1-a1-a1e-bravia-uhd-4k-oled-hdr-tv-review.13313
which has a valid URL
Code:
https://www.avforums.com/threads/alloy-repair.318860/
with an invalid internal looking URL appended
review/sony-kd-65a1-a1-a1e-bravia-uhd-4k-oled-hdr-tv-review.13313
although
Code:
https://www.avforums.com/review/sony-kd-65a1-a1-a1e-bravia-uhd-4k-oled-hdr-tv-review.13313
is valid.
Really strange.
Could it be that all non-slash-prefixed links on that page link to the page URL plus the link?
Any idea what the hell is going on?

Similarly inbound links to pages like
without the trailing slash are now broken. Loooooots of links.
With XF1, they appear to have been rewritten to
and worked. Or just worked without the trailing slash.
Again, is this a Xenforo 2 thing or something related to how the server needs setting up now?
Those pages were fine with Xenforo 1.

If it's a case of asking my hosts to alter nginx to append a trailing slash to every inbound url where there isn't one, I can do that.
But I would have thought Xenforo would be able to do it if it's required.

Similar issue mentioned here:
Thanks in advance.
 
XF 1 included a base tag in the output, which controlled the base for relative URLs in anchors.

Because this caused a few issues, XF2 doesn’t include this tag, so all relative URLs are relative to the current page. You’d either have to re-add the base tag, or update the relative URLs to include the leading slash, so as to be relative to the root domain path - or, even better, have them be rendered through the templates using the relevant syntax.

Your second issue isn’t the same, though - that’s just how string parameters work in XF2. The trailing slash is needed to its interpreted as a string parameter, rather than a route.

(You’ve also got some old XF1 template syntax in your privacy policy, by the way.)

Liam
 
Thanks Liam.
Because all the links in many pages have been indexed by Google, I ought to re-add the base tag.
Is there a method of doing that without an addon?

Also what's the best way to tackle inbound links missing the trailing slash? Must be able to do something rather than spit out a 404.

(You’ve also got some old XF1 template syntax in your privacy policy, by the way.)
Tell me about it. Like a **** ton of links and toggle triggers in pages scattered all over the place. Working my way through them.

@tiredjohn should have look at this.
 
Back
Top Bottom