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

Discussion in 'XenForo Questions and Support' started by Member 3639, Jun 19, 2011.

  1. Member 3639

    Member 3639 Active Member

  2. James

    James Well-Known Member

    Is the news prefix before the ID (429) always present?
     
  3. Member 3639

    Member 3639 Active Member

    Yeah it's always there :)
     
  4. Member 3639

    Member 3639 Active Member

  5. Jake Bunce

    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/
    
     
  6. Member 3639

    Member 3639 Active Member

    That still gives a 404 error when urls are loaded :(
     
  7. Jake Bunce

    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.
     
  8. Member 3639

    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.
     
  9. James

    James Well-Known Member

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

    Member 3639 Active Member

    The point here is that it's not picking up the html file with a 404 error.
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  12. Member 3639

    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.
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Is that the only thing in your htaccess file?
     
  14. James

    James Well-Known Member

    He's got it appended to XenForo's htaccess file.
     
  15. Jake Bunce

    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.
     
  16. Member 3639

    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 :/
     
  17. Brogan

    Brogan XenForo Moderator Staff Member

    As far as I understand it, any additional rewrite rules must be placed before the XenForo rules.
     
  18. Member 3639

    Member 3639 Active Member

    Jake appended it to the end as well and it still works.
     
  19. Member 3639

    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
     
  20. Brogan

    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.
     

Share This Page