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

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

Discussion in 'XenForo Questions and Support' started by Lone Wolf, May 27, 2015.

  1. Lone Wolf

    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.
     
  2. DaveAllen

    DaveAllen Member

    There is a great php script for performing mass changes that might work for you. (It has saved my sanity many times when moving WP sites and should work for your xenforo database too... However, if you do use this, backup your database first!
    Get The Script Here.

    Good luck!
     
    Lone Wolf likes this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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]
    
     
    Lone Wolf likes this.
  4. Lone Wolf

    Lone Wolf Well-Known Member

    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.
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That is difficult due to the route / directory conflict.

    Try this:

    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.
     
    Lone Wolf likes this.
  6. Lone Wolf

    Lone Wolf Well-Known Member

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

    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
    
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Use my exact code. But expand on the red part to specify as many routes as you want.
     
    Lone Wolf likes this.
  8. Lone Wolf

    Lone Wolf Well-Known Member

    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);
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    A new page or an existing page? Triggered by a specific action?
     
    Lone Wolf likes this.
  10. Lone Wolf

    Lone Wolf Well-Known Member

    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.
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

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

    Attached Files:

Share This Page