• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Redirects from sub-directory to root

Andy.N

Well-known member
#1
Can anyone help with a nginx rewrite rules that redirect all urls of the form

site.com/forum/threads/hedge-fund-or-investment-bank-internship.559/
into
site.com/threads/hedge-fund-or-investment-bank-internship.559/

I have XF installed on root and the first type of url was the result of XF previously being in /forum/ folder.

I have now moved it to root but Google reports thousands of 404 so I like to redirect them.
 

Andy.N

Well-known member
#4
Code:
location /forum/ {
    rewrite ^/forum/(.*)$ /$1 permanent;
}
That should do it.
Jake
I spoke too soon. Just realized that I have a route filter in place (forums/-> forum/)
After adding this rule, all the categories url gave 404
Going to site.com/forum/ will just display portal.

EDIT: it seems with the route filter in place, categories will be site.com/forum/category.1/
adding that rule in will break the url.
 
Last edited:

Jake Bunce

XenForo moderator
Staff member
#5
Jake
I spoke too soon. Just realized that I have a route filter in place (forums/-> forum/)
After adding this rule, all the categories url gave 404
Going to site.com/forum/ will just display portal.

EDIT: it seems with the route filter in place, categories will be site.com/forum/category.1/
adding that rule in will break the url.
You could attempt to distinguish the two patterns, but ideally you need to remove the conflict by removing that route change.