• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

need help adjusting xenforo htaccess for own use

Jake Bunce

XenForo moderator
Staff member
You are forcing me to learn this stuff. :confused:

Use this .htaccess code:

RedirectMatch 301 ^/news([^_]+)_([^.]+)\.html$ /index.php?threads/$2.$1/
It is in the web root, i am using the htaccess file that comes with Xenforo, just appending this to it as my xenforo install is in my root.


Well-known member
You are forcing me to learn this stuff. :confused:

Use this .htaccess code:

RedirectMatch 301 ^/news([^_]+)_([^.]+)\.html$ /index.php?threads/$2.$1/
You could just write it as such:
RedirectMatch 301 ^/news([^_]+)_([^.]+)\.html$ /index.php?threads/$1/
That should just use /threads/threadID
Yeah...and i understand this.

My point is instead of redirecting it gives a 404 not found (exactly what i said :p), the code is in the htaccess file but it doesn't seem to run.

Jake Bunce

XenForo moderator
Staff member
Your forum isn't using friendly URLs so you don't need those rewrite rules. But in my testing this redirect still works if you place it at the end of XenForo's htaccess file.
This is my htaccess from xenforo

#    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

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 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

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data|js|styles|install) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]

RedirectMatch 301 ^/news([^_]+)_([^.]+)\.html$ /index.php?threads/$2.$1/
That is currently at the website root, and as you can see it doesn't work :/


XenForo moderator
Staff member
You may need to tweak the rule slightly.
Different servers seem to handle them differently.

For example I can't use the non-www rule which is used here on xenforo.com on my server, I had to use a different one.

Edit: Never mind, looks like it's sorted.