XF 1.5 Moving from a subdir to root, need .htaccess changes and index route or route filters?

wcbryant

Active member
So I've done enough searching and reading (including, but not limited to, @Brogan's sig links) to understand that if moving from (domain)/forum to (domain) -- the root -- that I simply need to update Board URL in the ACP -> Options -> Basic Board Information.

My original plan was to have WordPress in the root and XF in the subdir, but I've never really made WP work the way I wanted -- the net result is too disjointed -- so I'm moving to XenPorta2 (at least until the devs here make their own standalone front end add-on *cough*). XP2 has to be installed in the same directory as the forum for obvious reasons, so to have that as my root page everything needs to move down to root, but I want to keep the appearance (and search engine links) as they exist now.

I still want the forum to appear as {root}/forum even if it's no longer physically located there. So my understanding is I need to set a Route Filter (edit: no, the more I look it seems to be Index Page Route)? If so, it is safe to say that my replace route would be "forum/"? Would my find route be "/"? And would I *not* want to check Incoming URL Conversion Only? Or is this what Index Route is about? Curiously, my active Index Page Route in Basic Board Information on my production site is "forums/" which isn't used at all (I'm installed in the /forum subdirectory and nothing shows up as "/forum/forums/" -- though I just noted that if I go to /forum/forums/ I'm simply redirected to /forum/. Seems like I need to adjust something there. Not sure if I need to change that or not. Clearly this is an area in which I'm not yet well grounded..

Here is my current .htaccess as it exists in /forum as put together by @Jake Bunce when he did an outstanding job migrating me from vB3 a few years back -- is there anything within that needs to change once it (along with everything else) moves to the root? Specifically I wonder about the rewrite rules within, but perhaps those will be okay with the route filter?

Code:
# Mod_security can interfere with uploading of content such as attachments. If you
# cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
# SecFilterEngine Off
# SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

#<Files "admin.php">
# AuthType Basic
# AuthName "AdminCP"
# AuthUserFile /{path}/(somefile).htpasswd
# Require valid-user
#</Files>

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /forum/threads/$1/page-$2 [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-.+\.html$ /forum/threads/$1/ [R=301,L]

# If you are having problems with the rewrite rules, remove the "#" from the
# line that begins "RewriteBase" below. You will also have to change the path
# of the rewrite to reflect the path to your XenForo installation.
#RewriteBase /xenforo

# This line may be needed to enable WebDAV editing with PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>

Ultimately, the goal is to have @Jaxel's xenPorta2 show up at the domain root, and when you click through to the forum it retains the appearance of the current structure (site/forum/), obviously since xenPorta2 has to be installed in the same directory I have to move the installation down to root and out of the forum/ subdir (unless I can get away with creating a symlink from xenporta's main page (assuming there is one, haven't yet installed it) to index.php in root.

Anyway, just want to tap the community knowledge base here before I tackle this, in case the way I think I need to do it isn't the best way to do so, and to try and catch issues before they happen. Do you all suppose people will have cached js issues after the move?

Not sure what else to look out for. I see people had issues because they didn't subsequently delete the old subdirectory, I'll be sure to do that.

Sorry if some of my phrasing is poor, I'm holding an 8 month old and she loves the keyboard. I'm also acutely aware that there have been a lot of threads about this, I've gleaned as much info from them (and a ton of reading in the XenPorta2 thread, the FAQ, manual, etc.) as I can, and am just hoping to tie it all together in my head.

Proactive thanks in advance; due to health issues I have to get this done (going to do it as part of the 1.5 upgrade) as quickly and efficiently as possible so just trying to get my ducks in a row beforehand.
 
Last edited:
That won't work. You can't fake a forum directory like that. Code changes would be required.

I might suggest leaving everything in the /forum directory and then setting up a redirect in your web root for the index.
 
Hey, Jake. Thanks for the response.

I may well have confused my message with the presentation. Before I go further, I fully appreciate that add-on support should be through the developer, but I want to distinguish this strictly as an issue about where my forum is installed, and whether or not I should be moving it to the domain root.

If you go to @Jaxel's site at 8wayrun.com, you have his xenPorta2 page, but when you click through to his forum you're then at 8wayrun.com/forums/.

xP2 and XF have to be installed in the same directory since the former is simply an add-on to the latter. My understanding was that he has everything installed in the root directory (not in {root}/forums/) and is simply using either Index Page Route or a Route Filter to lend the appearance of the forum having its own directory structure.

That said, if you think I can get away with installing xP2 in /forum/ and simply creating a symlink (if there's a standalone index php much the way vbAdvanced CMPS worked) or a special .htaccess rule in order to make this work, then that certainly seems easier than moving everything.

At the end of the day, I'm just nuking my WordPress install (in root), and need to have a xP2 generated front page in the root that leads people to my forum (my primary draw) in /forum/. If I can do that with a redirect and present the same way he does (essentially), then I'm all for it if that doesn't hurt me with the search engines. I thought front page redirects were sort of a bad thing, but if it's a symlink then it seems indistinguishable from a page in that directory.

Do you have a suggestion as to the form of the redirect?

And should I be removing /forums/ from my Index Page Route setting?

And not for nothing, a few years later, another thanks for your migration service. It was fantastic, has held up over time, and I couldn't possibly be happier about XF and this community.
 
Last edited:
I'm looking to redirect. Can you tell me easiest change to .htaccess to accomplish this?

I'm in /community and was using an htm redirect but would prefer to move it through .htaccess so it is seamless.
 
Top Bottom