Can WordPress and XenForo be installed in the same directory?

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?
 
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.
 
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?
 
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)
 
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)
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 ( / ) ?
 
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?
 
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:

Rich (BB 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?
 
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
 
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?
 
But this still involves doing some .htaccess wizardry.
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.
 
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.
 
Top Bottom