XF 1.5 Move & redirect XF to directory "community", after that Wordpress in the root?

snoopy5

Well-known member
Hi,

up to now, I had the xenforo forum installed in the root directory.

I moved all files now in the new directory "community" and put a htaccess file in the root, to keep all links to the postings working.

The htaccess file in the root is now:

Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /community/ [R=301]

So far, so good. Everything is working fine.

But now I would like to install Wordpress in the root.

Obviously this does not work because of that redirect.

How do I have to change that redirect, so that the old forum links are still working and at the same time I still can install Wordpress in the root?
 
Last edited:
Anybody?

I can not believe that this will be difficult.

The old structure before moving XF from the root into the directory "community" was

mysite.com/forums/titletexthere...

and

mysite.com/threads/titletexthere...

the new structure is now

mysite.com/community/forums/titletexthere...

mysite.com/community/threads/titletexthere...

All Worpress postings are without "community" or "forums" or "threads" in the URL. So there can not be confusion between Xenforo postings and Wordpress postings because of a redirect.

So what I need is a redirect code, that every incoming link to my server that tries to find the URL with the first words mysite.com/forums/
changes this to mysite.com/community/forums/ and every URL that starts with mysite.com/threads/ will be redirected to mysite.com/community/threads/

of course with a placeholder for the appropriate titletext after the slash so it ends up in the correct posting of the user in the forum.


Does anybody know how the redirect code has to be for this?
 
Hi Snoopy,

You may add this code to redirect forums from root to /community directory.
Code:
RewriteRule ^(threads|forums|members|posts|whats-new|online|help|login)/(.*)$ /community/$1/$2 [R=301,L]

Note: Remove the existing redirect well so going to domain.com won't forward to domain.com/community but XF base URLs would.
 
Hi Snoopy,

You may add this code to redirect forums from root to /community directory.
Code:
RewriteRule ^(threads|forums|members|posts|whats-new|online|help|login)/(.*)$ /community/$1/$2 [R=301,L]

Note: Remove the existing redirect well so going to domain.com won't forward to domain.com/community but XF base URLs would.


mmmhhhh...

this does not work yet. Maybe it is in conflict with the htaccess file of wordpress?

This is what I have at the moment in the htaccess file located in the root:

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(threads|forums|members|posts|whats-new|online|help|login)/(.*)$ /community/$1/$2 [R=301,L]

but it ends up in a Wordpress page with error: "Oops! That page can’t be found."
 
I have the solution 💥

Instead of
RewriteCond %{REQUEST_URI} ^/$
I put

RewriteCond %{HTTP_HOST} ^(.*)$


So the whole code in the htaccess file of wordpress is:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^(threads|forums|members|posts|whats-new|online|help|login)/(.*)$ /community/$1/$2 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
 
I have the solution 💥

Instead of
RewriteCond %{REQUEST_URI} ^/$
I put

RewriteCond %{HTTP_HOST} ^(.*)$


So the whole code in the htaccess file of wordpress is:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^(threads|forums|members|posts|whats-new|online|help|login)/(.*)$ /community/$1/$2 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
You rock!
 
Top Bottom