XF 2.2 Setup redirections in Xenforo

ritesh

Member
Hello, as I've mentioned in my previous posts, I'm migrating my WordPress blog to Xenforo.

WordPress has a different URL structure, ex: https://example.com/hello-post

But Xenforo has a different URL structure. I've about 10 pages on WordPress that I need to redirect when I migrate the content to Xenforo.

How can I do that?

PS: site's domain is the same. Just the CMS is being changed
 
Sigh ...

A paid "add-on" is ridiculous for rewrite rules.
Something which can be implemented quickly and easily on the server.

But it's your money.

I'm not a coder. I would really appreciate it if you share a simple example of htaccess redirection for my purpose. I have looked for tutorials, and all of them have different codes, and I'm not sure which one I should use.
 
There is also this free add-on which handles redirects and some more interesting stuff:

Or if you want to keep it simple, create a .htaccess file in the root directory:
Code:
Redirect 301 /old-page https://www.domain.com/xf/new-page
 
I'm wondering which .htaccess file it should go in. I see in the Xenforo upload folder there is an .htaccess and an htaccess.txt in the upload folder. What is the .txt for? The contents of both files are identical.

The guide I followed had me run these commands to move both the files and hidden files when I first uploaded and installed Xenforo:
mv upload/* .
mv upload/*. .
And it resulted in an error, which the person said to ignore because it always happens.

But now when I look at my public folder there is no .htaccess, only htaccess.txt.

There are other .htaccess files at:
/home/nginx/domains/forum.mysite.com/public/src/.htaccess
/home/nginx/domains/forum.mysite.com/public/internal_data/.htaccess
/home/nginx/domains/forum.mysite.com/public/library/.htaccess

Do I need to upload the .htaccess to the public folder? If so, I'm worried that other important files also didn't copy.

The default content of Xenforo's base .htaccess file is:
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 /xenforo

    #    This line may be needed to workaround HTTP Basic auth issues when using 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>

Would I just add a standard rewrite rule at the end? IE:
Code:
    #    This line may be needed to workaround HTTP Basic auth issues when using 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>

Redirect 301 /threads/.47/ /threads/.68/

I also found this thread https://xenforo.com/community/threads/redirecting-thread-urls.168090/#post-1364839 that showed an example using the route filter. In find route could I put /threads/.47/ and replace with put /threads/.68/?
EDIT: The route filter code didn't work.
https://forum.mysite.com/threads/full-thread-url.47/ is the "oops not found" page.
https://forum.mysite.com/threads/.47/ gives me 403 Forbidden nginx.

EDIT:
Well I found a way to do it with Centmin Mod:
Centmin Mod redirects: www.youtube.com/watch?v=tEwliqSt1Zg&t=8m2s
/usr/local/nginx/conf/conf.d/redirects.conf
Code:
map $request_uri $redirect_uri {

/threads/47/    /threads/59/;
/threads/long-url.47/    /threads/long-url.59/;

}

You DO have to do ngxrestart each time. And you have to put both the long AND short URLs.

For some reason /threads/.47/ does not work. There has to be at least one (random) character before the period. IE: /threads/t.47/.
 
Last edited:
Top Bottom