XF 2.0 Route requires slash for it to work.

koa

Member
When trying to, let's say, make a route for a thread (threads/vote.123) to vote/, I was hoping that the slash wouldn't be required, so example.com/vote would still forward to the specified route.

Is the slash required, or is there any way to make routing work without the slash?



ULb4l59.png
 
This is generally expected. If it's important for you to cover the version without the final slash, you may need to do a specific redirect for it, such as via .htaccess.
 
I'd have to check exactly how XF1 is processing it, but given the route filter in use, a route of "vote" doesn't match when it's looking for "vote/".
 
the lack of a trailing slash always worked in xf1. if you're going to write down a url for a friend it's unlikely you're going to include the trailing slash, or if someone gives the url via word of mouth, or in a chat, 90% chance they're not going to give the trailing slash.

so, this has kind of broken a lot of my route filters after upgrading to xf2; it would be nice if we could fix this to work as I believe most people would use it, maybe a feature suggestion for a future version?
 
I'd be okay with doing this, but I'm not sure how to accomplish it in nginx.

okay, so i'm posting this here in case anyone else comes across it via google or whatever. I'm currently using this in my vhost in nginx:

Code:
rewrite ^([^.\?]*[^/])$ $1/ permanent;

placed right above the "try_files" directive in the "location /" block.

I'm using Marc's example from this page:

https://stackoverflow.com/questions...-end-of-every-url-need-rewrite-rule-for-nginx

seems to be working so far, i'll post here if it causes any problems.

i take that back, it breaks just about any addon that doesn't use a trailing slash, and some routes as well. i guess i'll have to come back to this idea later.
 
Last edited:
Back
Top Bottom