Announcement

Collapse
No announcement yet.

Mod Rewrite Friendly URLs => .htaccess

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mod Rewrite Friendly URLs => .htaccess

    There is no .htaccess to support the "Mod Rewrite Friendly URLs", so I have one written below, the first 3 are just a little beta bug proofing.

    I can not guarantee this is perfect, but it's working so far, if I find any bugs, I'll squish em and edit in an updated version

    Download: http://www.phpatlas.com/vBulletin/htaccess

    Code:
    # Author: Matty Asia
    # Version 1.6
    # Downloaded from: http://www.vbulletin.com/forum/showthread.php?325798
    
    RewriteEngine On
    Options +FollowSymLinks
    
    ### THIS IS A LITTLE EXTRA SECURITY AND CAN BE REMOVED
    
    RewriteRule ^includes/(.*) index.php
    RewriteRule ^vb/(.*) index.php
    RewriteRule ^packages/(.*) index.php
    
    ### THIS IS THE ACTUAL REWRITE
    
    RewriteRule ^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) showthread.php?t=$1&page=$2&%{QUERY_STRING}
    RewriteRule ^members/([0-9]+) member.php?u=$1&%{QUERY_STRING}
    RewriteRule ^forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) forumdisplay.php?f=$1&page=$2&%{QUERY_STRING}
    RewriteRule ^blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) blog.php?u=$1&page=$2&%{QUERY_STRING}
    RewriteRule ^entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) entry.php?b=$1&page=$2&%{QUERY_STRING}
    RewriteRule ^list/([^/]*/)([0-9]+) list.php?r=$1$2&%{QUERY_STRING}
    RewriteRule ^content/(.*) content.php?r=$1&%{QUERY_STRING}
    RewriteRule ^widget/config/([0-9]+) widget.php?r=config/$1&%{QUERY_STRING}
    To use this you must have Mod Rewrite Friendly URLs enabled.

    To do this...
    You need to go to Admin Control Panel then Settings > Options
    Server Settings and Optimization Options
    Then select Mod Rewrite Friendly URLs in the Friendly URLs section.

    UPDATES:
    1.6 Added ... Widget bit
    1.5 Added ... Options +FollowSymLinks
    1.4 Fixed content editing for CMS sections without SEO friendly names

    If you get Error 500, check the .htaccess file for any \n hidden anywhere as seems to have appeared for a number of users copying from here, see the quote just below. Make sure what you copy is identical to what you see above.

    Originally posted by snerd View Post
    Well, looks like it's getting munged and the line is not complete:

    RewriteRule: cannot compile regular expression '^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?))'\n
    That '\n is appearing when I copy to the .htaccess for some reason.
    Last edited by MattyAsia; Tue 8th Dec '09, 12:31pm.

  • #2
    It doesn't work for me ;(

    Comment


    • #3
      Originally posted by gotski View Post
      It doesn't work for me ;(
      Did you set vBulletin to use "Mod Rewrite Friendly URLs"?
      You need to go to Admin Control Panel then Settings > Options
      Help
      Server Settings and Optimization Options
      Then select Mod Rewrite Friendly URLs in the Friendly URLs section.

      Comment


      • #4
        No work here either, 500 Internal Server Error
        snerd

        Comment


        • #5
          Originally posted by snerd View Post
          No work here either, 500 Internal Server Error
          Have you done rewrites before?
          In httpd.conf make sure
          #LoadModule rewrite_module modules/mod_rewrite.so
          is
          LoadModule rewrite_module modules/mod_rewrite.so

          then restart apahce.

          Comment


          • #6
            Seems to be working well for me.

            Thanks for posting this.

            Comment


            • #7
              Originally posted by sifuhall View Post
              Seems to be working well for me.

              Thanks for posting this.
              No problem, but keep checking back, I keep finding small issues and updating them, you can tell if yours is up to date via the version number.

              Comment


              • #8
                For some reason these don't work on nginx (basic conversions applied obviously) - must be something weird about the regexes :/
                vB4 SuperCharged
                http://www.gamingmasters.co.uk

                Comment


                • #9
                  Works flawlessly for me on my local environment.
                  Thanks!
                  Last edited by nubian; Sun 15th Nov '09, 7:22am.

                  Comment


                  • #10
                    Great code, thank you

                    vBulletin QA - vBulletin Support French - Lead Project Tools developer

                    Next release? Soon(tm)

                    Comment


                    • #11
                      If you use IIS add

                      $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
                      to the top of class_core.php.
                      Admins Zone - Resources for Forum Administrators

                      Comment


                      • #12
                        I'm on a shared server, but have used vBseo .htaccess for rewriting on old version. This .htaccess just gets the internal server error.
                        snerd

                        Comment


                        • #13
                          check your error logs.

                          what is the actual error?

                          Comment


                          • #14
                            Originally posted by sifuhall View Post
                            check your error logs.

                            what is the actual error?
                            Well, looks like it's getting munged and the line is not complete:

                            RewriteRule: cannot compile regular expression '^threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?))'\n
                            That '\n is appearing when I copy to the .htaccess for some reason.
                            snerd

                            Comment


                            • #15
                              thx matty asia im testing too

                              Comment

                              Related Topics

                              Collapse

                              Working...
                              X