XF 1.4 I moved the XenForo install folder and now lots of links are broken

Lone Wolf

Well-known member
I recently moved my XenForo forum to a new server, in the process I moved the installation from /forums to /root

I also had the route changer by @Jake Bunce installed before and now lots of links both internal and incoming are resolving as errors. I have a few examples below...

Individual Forums

https://www.mydomain.com/forums/view/main_forum/ - old
https://www.mydomain.com/forums/main_forum/ - new

Individual Threads


https://www.mydomain.com/forums/threads/thread-one/ - old
https://www.mydomain.com/threads/thread-one/ - new


What's the best way have the incoming links redirect to the new structure and is there a way to change any find and replace any links inside the forum itself.
 
Use route filters to change the 'forums' route to 'view' (like before). Then remove the old /forums directory. Then add these rules to the top of the .htaccess file in your web root (XF's .htaccess file) to redirect all old traffic:

Code:
RewriteEngine on

RewriteRule ^forums/(.*)$ /$1 [R=301,L]
 
Use route filters to change the 'forums' route to 'view' (like before). Then remove the old /forums directory. Then add these rules to the top of the .htaccess file in your web root (XF's .htaccess file) to redirect all old traffic:

Code:
RewriteEngine on

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

I dont want to change the forums route to view. I'd like to keep the new URLS as they are and just have the old URLs direct to the new ones.
 
I dont want to change the forums route to view. I'd like to keep the new URLS as they are and just have the old URLs direct to the new ones.

That is difficult due to the route / directory conflict.

Try this:

Rich (BB code):
RewriteEngine on

RewriteRule ^forums/view/(.+)$ /forums/$1 [R=301,L]
RewriteRule ^forums/(threads|attachments|members)/(.*)$ /$1/$2 [R=301,L]

To avoid possible conflicts you need to manually list all routes you want to redirect. And the 'view' route has its own rule.
 
That is difficult due to the route / directory conflict.

Try this:

Rich (BB code):
RewriteEngine on

RewriteRule ^forums/view/(.+)$ /forums/$1 [R=301,L]
RewriteRule ^forums/(threads|attachments|members)/(.*)$ /$1/$2 [R=301,L]

To avoid possible conflicts you need to manually list all routes you want to redirect. And the 'view' route has its own rule.

So I put this in the .htaccess file...

Rich (BB code):
RewriteEngine on

RewriteRule ^forums/view/(.+)$ /forums/$1 [R=301,L]
RewriteRule ^forums/threads/(.*)$ /$1/$2 [R=301,L
RewriteRule ^forums/attachments/(.*)$ /$1/$2 [R=301,L
RewriteRule ^forums/members/(.*)$ /$1/$2 [R=301,L
[/code]
 
So I put this in the .htaccess file...

Rich (BB code):
RewriteEngine on

RewriteRule ^forums/view/(.+)$ /forums/$1 [R=301,L]
RewriteRule ^forums/threads/(.*)$ /$1/$2 [R=301,L
RewriteRule ^forums/attachments/(.*)$ /$1/$2 [R=301,L
RewriteRule ^forums/members/(.*)$ /$1/$2 [R=301,L
[/code]
Rich (BB code):
Use my exact code.  But expand on the red part to specify as many routes as you want.
 
Use my exact code. But expand on the red part to specify as many routes as you want.

Oh right, I thought you meant use only the red options I want on a separate line. Thanks for that Jake, that's working now.

Whilst I have you here do you know how I can make a page with a php callback and then execute the following code in the callback...

Code:
XenForo_Application::setSimpleCacheData('mostUsers', 1386);
 
Oh right, I thought you meant use only the red options I want on a separate line. Thanks for that Jake, that's working now.

Whilst I have you here do you know how I can make a page with a php callback and then execute the following code in the callback...

Code:
XenForo_Application::setSimpleCacheData('mostUsers', 1386);

A new page or an existing page? Triggered by a specific action?
 
A new page or an existing page? Triggered by a specific action?

I moved my old forum into a new XF database and that reset the most users online number from 1,386 back to 0 and I just want to set it back to the that number again. Jaxel said I cold do it like this by settn gup a new page and executing a PHP callback in it...

https://xenforo.com/community/threa...a-2-portal-pro-paid.89112/page-78#post-938158

But I dont know what any of that means. I know you're good with this stuff.
 
I moved my old forum into a new XF database and that reset the most users online number from 1,386 back to 0 and I just want to set it back to the that number again. Jaxel said I cold do it like this by settn gup a new page and executing a PHP callback in it...

https://xenforo.com/community/threa...a-2-portal-pro-paid.89112/page-78#post-938158

But I dont know what any of that means. I know you're good with this stuff.

To run it one time, use this script which includes that code. Upload it to your xf directory and visit it in your browser.
 

Attachments

Top Bottom