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

Can WordPress and XenForo be installed in the same directory?

Discussion in 'Off Topic' started by TheBigK, Oct 9, 2016.

  1. TheBigK

    TheBigK Well-Known Member

    I'm wondering if it's possible to install XF and WP in the same directory on the web server, without disturbing existing setup. If yes, what would need to be tweaked?
     
  2. Optic

    Optic Well-Known Member

    The main issue of course is only one index.php can be in the root, which one do you want as the front page?

    Would be much easier to have either WP or XF in a separate directory.
     
  3. SneakyDave

    SneakyDave Well-Known Member

    Well, you'd have to find a way to use both WordPress' and Xenforo's index.php file. That might be the hardest part
     
  4. TheBigK

    TheBigK Well-Known Member

    Well, the main reason is that I do not wish to disturb my existing XF setup. Is it even possible to keep the URL structure just as it is; while switching XF to a new directory?

    Example:

    Current URL: domain.com/threads/thread-title.123/
    With XF in the root folder.

    Can I now switch XF to a sub-folder and still have the above URL structure?
     
  5. Optic

    Optic Well-Known Member

    I think you could use mod_rewrite in .htaccess to redirect all the XF URLs to point to XF being in a subfolder? You'd have to cover at least these suffixes:
    yourforum.com/members|threads|posts|attachments|profile-posts|forums
    (also assuming it doesn't conflict with any XF route filters you may have defined)
     
  6. TheBigK

    TheBigK Well-Known Member

    Interesting. There aren't any custom route filters.

    Could you please tell me what'd be the .htaccess rule if the subfolder I'm moving to is, say /xf/ from root ( / ) ?
     
  7. Optic

    Optic Well-Known Member

  8. TheBigK

    TheBigK Well-Known Member

    Interesting. I think the rule is straightforward if you want to point to subdirectory; but when the install files are in a sub-directory, I think it'd be kinda difficult to keep the URL intact.

    @Jake Bunce - Is it possible to keep the URL intact while moving XF install from root to a subdirectory?
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Normally you would setup a selective redirect to redirect the old XF routes to the new location. Use these rules in the web root's .htaccess file:

    Code:
    RewriteEngine on
    
    RewriteRule ^(threads|forums|members|posts|attachments)/(.*)$ /newdir/$1/$2 [R=301,L]
    
    But I have never done exactly what you want. I suspect it is possible. There may be special considerations with the request headers and pathing within XenForo. I will experiment with this later tonight. Are you on Apache?
     
  10. TheBigK

    TheBigK Well-Known Member

    I'm on LiteSpeed, which is a drop replacement of Apache.
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I am encountering expected problems with this directory aliasing. I haven't been able to get it working.
     
  12. TheBigK

    TheBigK Well-Known Member

    Hmm. Looks like the only way to get this to work is to move XF in its own subdirectory and setup redirects.
     
  13. DPF

    DPF Active Member

    You can get them to work in the same directory pretty easy. Logistically though it could become muddled when they are competing for URLs but that's easily overcame by giving Wordpress custom URL settings in the admin area.

    A quick google search of Wordpress rename index.php yielded good results
     
    TheBigK likes this.
  14. TheBigK

    TheBigK Well-Known Member

    I think the only way is to rename index.php to something else; say 'wpindex.php' and then install both WP and Forum in the same directory. But this still involves doing some .htaccess wizardry.

    @DPF - Have you been able to get this to work?
     
  15. Mr Lucky

    Mr Lucky Well-Known Member

    I think wizardry is exactly what it will be. I would trust jake Bunce to be very good at this.

    Presumably it's an established forum with backlinks? If not I would worry too much about redirects as Serach engines pick things up quickly. But if you have other sites linking to individual pages/threads then you need to have aredirects that nly affect XenForo, not the Wordpress files/folders and that is where I get a bit lost.

    Alternatively if the forum is established, but the wordpress is new (or moved form a different URL), then how about keeping the forum in the root and installing Wordpress in the subdirectory. That way the only redirects need would be form the old wordpress URL if it has been moved.
     
  16. TheBigK

    TheBigK Well-Known Member

    @Mr Lucky - You are right; if it wasn't an established forum; I'd not care at all. My options are very limited.
     
  17. Robru

    Robru Active Member

    I have done the same in December 2016.
    Wordpress placed in the root and XF that was in the root moved to the directory 'community'.
    Jake code used in the .htaccess file in the root.
    It took at least 3 weeks before the search engines again were on the right track.
     
  18. Mr Lucky

    Mr Lucky Well-Known Member

    But the new URLs not being listed for three weeks is no problem at all, provided the redirects are working.
     
  19. Robru

    Robru Active Member

    Correct!
     

Share This Page