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:

Code:
RedirectMatch 301 ^/news([^_]+)_([^.]+)\.html$ /index.php?threads/$2.$1/
 

Jake Bunce

XenForo moderator
Staff member
I tested it thoroughly so I know it works. In your case that .htaccess file should be in the web root.
 

Member 3639

Active member
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.
 

James

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

Use this .htaccess code:

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

Member 3639

Active member
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.
 

Member 3639

Active member
This is my htaccess from xenforo

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

<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]
</IfModule>

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 :/
 

Brogan

XenForo moderator
Staff member
As far as I understand it, any additional rewrite rules must be placed before the XenForo rules.
 

Member 3639

Active member
Hah oh dear, my bad all along, windows kept renaming it .txt so i was uploading a text file <_<

Thanks for the help guys :D
 

Brogan

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.
 
Top