XF 1.5 .htaccess redirect after vB4.2 import

zl-oa

Member
Background: Coming from vB4.2 installed in <webroot>/forums
moving to Xenforo 1.5 in <webroot>/community
Using Friendly URLS in Xenforo
No homepage yet at www.zl-oa.com (will most likely go wordpress down the line) but for now I want to redirect that url to www.zl-oa/community


I started out following @Brogan 's "thread: https://xenforo.com/community/threads/importing-guidelines.25325/

Then it sent me here: https://xenforo.com/community/resources/vbulletin-4-x-url-redirection.120/
Where I uploaded the PHP files to <webroot>/community
I also added this to the .htaccess in <webroot>/community

Code:
rewrite ^/showthread.php /showthread.php;
rewrite ^/forumdisplay.php /forumdisplay.php;

#Changing directory
RewriteRule ^/old-dir/showthread.php /new-dir/showthread.php
RewriteRule ^/old-dir/forumdisplay.php /new-dir/forumdisplay.php

Finally I went and edited the 301config.php in <webroot>/community
as directed here: https://xenforo.com/help/import-redirection/
Code:
<?php

\* ----------------------------------------------------------- */

    $fileDir = '/home/<mycpanelname>/public_html/community';

/* ----------------------------------------------------------- *\

    define('IMPORT_LOG_TABLE', 'archived_import_log');


Nothing seems to be working unless I go directly to zl-oa.com/community
But old vB links inside posts are still broken, and they are broke if you follow them from google too.

I hope somebody could help me out, I have read so many threads here about .htaccess that I actually have a headache now. Trying to go live with the site by Friday if possible.

So here is <webroot>/community/.htaccess in full
Let's assume I don't have a .htaccess anywhere else and go from there.

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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    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 /community
    rewrite ^/showthread.php /showthread.php;
    rewrite ^/forumdisplay.php /forumdisplay.php;

    #    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]
    RewriteRule ^/forums/showthread.php /community/showthread.php
    RewriteRule ^/forums/forumdisplay.php /community/forumdisplay.php
</IfModule>

Perhaps the ninja @Jake Bunce will chime in, or if @Brogan is around?
Thanks in advance!

Almost forgot...Jake would ask for the old and new URL's...so here they are:

Old vB4.2 and Google: http://www.zl-oa.com/forums/showthread.php?14919-CARB-REBUILD-KIT-by-K-amp-L

New Xenforo: http://www.zl-oa.com/community/threads/carb-rebuild-kit-by-k-l.14919/
 
Last edited:
Still have trouble guys, will try anything even if your an .htaccess newb like me :D

So I fixed redirecting all my domain traffic @ zl-oa.com to go to zl-oa.com/community by putting this in the <webroot>

Code:
RewriteEngine On
#Use this line to traverse silently
#RewriteRule ^(.*)$ /community/$1 [L]

#Use this line to traverse with subfolder displayed
RewriteRule ^$ /community [L]

But I still can't get redirects to work in the /community folder. They still try to go to the old /forums folder.
Here is what I have in <webroot>/community as of right now.

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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    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 /community
    
    #    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]
    RewriteRule ^/forums/showthread.php /community/showthread.php
    RewriteRule ^/forums/forumdisplay.php /community/forumdisplay.php
</IfModule>

So if you see the two rewriteRules at the bottom, I thought this would take care of my issue but it isn't working.
 
It's simplest if you put the redirect scripts in the old location (/forums, recreate the directory if necessary) and then set up your 301config.php file to point to the new location (what you did). If you hit one of the old URLs, you should end up at the new URL.

The .htaccess that you put in the root may well be interfering. If you want to redirect the root to a sub-directory, I'd recommend 301ing it:
Code:
RewriteRule ^$ /community/ [L,R=301]
 
Thanks @Mike
Updated the root .htaccess as 301

Moved all rewrite scripts into the old and empty /forums folder.

It's still not quite right.
Did you want me to move the /community .htaccess into the /forums folder also?
 
OK Disregard. Works great now. My browser cached the page before.
left .htaccess in the /community folder and refreshed browser.
Links from google work again now as well.

Just a closing question since I'm not great with SEO.
From what I understand as spiders crawl my site now they will update the old URLS to the new ones?
Am I correct in thinking that...
Or does the spider engine make a brand new entry and the old ones just get redirected on my site?

Again thanks!
 
Top Bottom