XF 2.0 Redirect from /forums/ to root

Mr Lucky

Well-known member
I have one forum that is installed in /forums/ but I now need to move it to the root.

Normally I would use this in .htaccess
Code:
RewriteRule ^forums/(.*)$ /$1 [R=301,NC,L]
but of course that messes with the xenForo path for the forum list and the forums themeselves, and so the Forums tab just gets redirected to the home page.

I have a route filter changing forums/ to forum/ . This allows the forum navigation tab to work, but any external inbound links with /forums/ don't work


(Obviously a similar redirect works fine for my other forum that is redirected out of /community/ but of course that does not conflict with the xenForo /forums/ URL)

Does anyone please know a way round this or are we stuck forever with the xenforo installed in /forums?

Thanks
 
Essentially, you would need to redirect specific sub-routes that don't conflict, so things like forums/forums/ and forums/threads/. This won't cover every URL -- you'd need to list all the ones you want -- but it should cover most of the common cases.
 
Thanks that makes sense. So I'd probably only need:

forums/forums/ to forums/
forums/threads/ to threads/
forums/resources/ to resources/

to cover most common eventualities of external links/bookmarks.

My problem now then is finding the .htaccess to do that, nothing I've tried works, e.g:

Code:
RewriteRule ^forums/forums/(.*)$ /forums/$1 [R=301,NC,L]

does anyone know what I'd need?

Thanks
 
I think that'd work, though make sure you're trying with a fresh URL each time to avoid browser caching issues. Beyond that, make sure you've removed the "general" rule, as the first match will be triggered.
 
OK, it is working now. maybe it just needed you to say it should. Redirects are voodoo IMO. Or it was cache thing. (I blame most things on cache)

Thanks.
 
Redirects are voodoo IMO. Or it was cache thing. (I blame most things on cache)

Don't forget that most browsers now aggressively cache 301 redirects - even ignoring Ctrl-F5 and such and ignoring any changes you make to your code or web server config.

You basically need to clear the cache completely to get rid of them - or while testing, use a 302 redirect and then change it to 301 once you're happy it works.

I find testing redirects in incognito mode generally works better - I believe the cache is flushed when the incognito browser is closed.
 
Don't forget that most browsers now aggressively cache 301 redirects - even ignoring Ctrl-F5 and such and ignoring any changes you make to your code or web server config.

You basically need to clear the cache completely to get rid of them - or while testing, use a 302 redirect and then change it to 301 once you're happy it works.

I find testing redirects in incognito mode generally works better - I believe the cache is flushed when the incognito browser is closed.

Thanks, this sounds useful
 
Hello everyone
We moved our forum from root to forums folder
this should be ok?
RewriteRule ^forums/(.*)$ /forums/forums/$1 [R=301,NC,L]
RewriteRule ^threads/(.*)$ /forums/threads/$1 [R=301,NC,L]
RewriteRule ^resources/(.*)$ /forums/resources/$1 [R=301,NC,L]
 
Top Bottom