Mod Rewrite Friendly URLs => .htaccess

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Graex
    New Member
    • Mar 2010
    • 20
    • 4.0.0

    I had the issue with the "500 Internal Error" and none of the earlier .htaccess in this thread worked for me.

    However I found a .htaccess solution wich works very well for me from vbulletin.org

    Link: http://www.vbulletin.org/forum/showt...39#post1999837

    It seems to be made for Apache 1.3 (I'm not sure which version my host is using but it works!)

    Hope it helps someone.
    Last edited by Graex; Fri 26 Mar '10, 9:17pm. Reason: Accidently put the wrong link, fixed.

    Comment

    • kristinprimal
      New Member
      • Mar 2010
      • 6
      • 4.0.0

      what I'd really like now is a way to remove the forum number in the friendly URL.

      i.e., right now it is showing:


      and I'd like it to just say:


      Anyone know a way to do this? It doesn't have to be part of the product, if someone can tell me what .php file to change and where, and what to put in .htaccess, that would work for me too.

      thanks very much~

      Comment

      • iettafune
        Member
        • Oct 2007
        • 57

        Originally posted by MattyAsia
        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.

        why, when I delete a topic, i receive this error:

        Not Found

        The requested document was not found on this server.
        Web Server at site.it

        Comment

        • Jaxel
          Member
          • Jun 2006
          • 88

          I'm discovered a significant error with these rewrite rules... ANCHOR NAMES dont work...

          Try testing it yourself, go into any template and add the lines:

          Code:
          <a name="test"></a>
          <a href="#test">test</a>
          Instead of the anchor sticking to the page with currentpage#test, it will always revert to /#test insted.

          Comment

          • Bacon Butty
            Senior Member
            • Jun 2005
            • 162

            Thanks very much for everyone who has replied in this thread trying to offer assistance. I've tried all the codes but no joy so far.

            I did have vbSEO on my vBulletin 3.8 installation. I upgraded to 4.0 and selected 'Mod Rewrite Friendly URLs'. My current= .htaccess is the one defined at the start of this thread;

            # 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}
            However, when someone attempts to visit an old url on Google, say from searching 'Everton Grand National' on my website, they are attempted to be diverted to this page, which gives them an error;

            The actual link for that said thread is now infact;

            I've tried to resolve this for literally hours, if any of you clever lot can resolve I'll be very grateful!

            Comment

            • Bacon Butty
              Senior Member
              • Jun 2005
              • 162

              Should what I've asked above be asked on vbSEO?

              Comment

              • Oracle simsim
                Senior Member
                • Jul 2009
                • 117

                Thank you I tested that and work great, but because my forum is Arabic, I can't use any type of friendly SEO url
                منتديات درر العراق

                Comment

                • thanhdat
                  Member
                  • Feb 2005
                  • 79
                  • 3.8.x

                  Should I have buy vBSEO?
                  Vui Ve Club - www.vuiveclub.net

                  Comment

                  • obmob
                    Senior Member
                    • Sep 2001
                    • 278

                    Originally posted by thanhdat
                    Should I have buy vBSEO?
                    No, you dont need vBSEO, but i guess if you used to use it, you might need to add an extra forward because of the .html extension.

                    Don't ask me how to do it, sorry not a coder. Barely made it work on my site ^^,
                    Currently working on:
                    Anizeen - What anime have you seen?
                    Osito Barrigón - Winnie Pooh y sus Amigos

                    Comment

                    • Jaxel
                      Member
                      • Jun 2006
                      • 88

                      I'm having an issue with my 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}
                      
                      ### Media Library
                      ReWriteRule ^media/m([0-9]+).*/tags$ media.php?do=tags_edit&mid=$1 [QSA]
                      ReWriteRule ^media/m([0-9]+).*/edit$ media.php?do=details_edit&mid=$1 [QSA]
                      ReWriteRule ^media/m([0-9]+).*/report$ media.php?do=report&mid=$1 [QSA]
                      ReWriteRule ^media/m([0-9]+).*/c([0-9]+)$ media.php?do=comment_edit&cmt=$2 [QSA]
                      ReWriteRule ^media/m([0-9]+).* media.php?do=details&mid=$1 [QSA]
                      ReWriteRule ^media/c([0-9]+).* media.php?do=category&cid=$1 [QSA]
                      ReWriteRule ^media/u([0-9]+).* media.php?do=user&uid=$1 [QSA]
                      ReWriteRule ^media/tag/(.*) media.php?do=tag&tid=$1 [QSA]
                      ReWriteRule ^media/tagcloud.* media.php?do=tag_cloud [QSA]
                      ReWriteRule ^media/search/(.*).* media.php?do=search&query=$1 [QSA]
                      ReWriteRule ^media/submit.* media.php?do=submit [QSA]
                      ReWriteRule ^media/random.* media.php?do=random [QSA]
                      ReWriteRule ^media/admin/(\w+).* media.php?do=admin_$1 [QSA]
                      I occasionally get this error:
                      Warning: Invalid argument supplied for foreach() in [path]/packages/vbcms/widget/recentcmscomments.php on line 319

                      Only happens with THIS htaccess. When I use the htaccess below, I don't have this error, but then anchors seem to break...

                      Code:
                      RewriteEngine on
                      
                      RewriteCond %{REQUEST_FILENAME} -s [OR]
                      RewriteCond %{REQUEST_FILENAME} -l [OR]
                      RewriteCond %{REQUEST_FILENAME} -d
                      
                      RewriteRule ^.*$ - [NC,L]
                      
                      # Media Library
                      ReWriteRule ^media/m([0-9]+).*/tags$ media.php?do=tags_edit&mid=$1 [QSA]
                      ReWriteRule ^media/m([0-9]+).*/edit$ media.php?do=details_edit&mid=$1 [QSA]
                      ReWriteRule ^media/m([0-9]+).*/report$ media.php?do=report&mid=$1 [QSA]
                      ReWriteRule ^media/m([0-9]+).*/c([0-9]+)$ media.php?do=comment_edit&cmt=$2 [QSA]
                      ReWriteRule ^media/m([0-9]+).* media.php?do=details&mid=$1 [QSA]
                      ReWriteRule ^media/c([0-9]+).* media.php?do=category&cid=$1 [QSA]
                      ReWriteRule ^media/u([0-9]+).* media.php?do=user&uid=$1 [QSA]
                      ReWriteRule ^media/tag/(.*) media.php?do=tag&tid=$1 [QSA]
                      ReWriteRule ^media/tagcloud.* media.php?do=tag_cloud [QSA]
                      ReWriteRule ^media/search/(.*).* media.php?do=search&query=$1 [QSA]
                      ReWriteRule ^media/submit.* media.php?do=submit [QSA]
                      ReWriteRule ^media/random.* media.php?do=random [QSA]
                      ReWriteRule ^media/admin/(\w+).* media.php?do=admin_$1 [QSA]
                      
                      # Forum
                      RewriteRule ^threads/.* showthread.php [QSA]
                      RewriteRule ^forums/.* forumdisplay.php [QSA]
                      RewriteRule ^members/.* member.php [QSA]
                      RewriteRule ^blogs/.* blog.php [QSA]
                      ReWriteRule ^entries/.* entry.php [QSA]
                      
                      RewriteCond %{REQUEST_FILENAME} -s [OR]
                      RewriteCond %{REQUEST_FILENAME} -l [OR]
                      RewriteCond %{REQUEST_FILENAME} -d
                      
                      RewriteRule ^.*$ - [NC,L]
                      
                      # MVC
                      RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]

                      Comment

                      • cvn
                        Member
                        • May 2006
                        • 37

                        I initially had my board installed in mydomain.com/forums and had the same problem as the OP did. But after being upgraded to 4.0.3 the problem is fixed.

                        Today I moved my board to the root directory of mydomain.com/ The Mod rewrite Friendly URLs work OK still. However in order to have the backlinks still go the the right place, I had to place the following .htaccess file in /forums/ directory:

                        Code:
                        RewriteEngine on
                        Options +FollowSymLinks
                        RewriteBase /forums
                        RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
                        But if I do that the forumdisplay links are rewritten, for instance to http://mydomain.com/11-test, instead of http://mydomain.com/forums/11-test as it should be. Then error.

                        I think the problem can be fixed if I know how to make the forumdisplays link rewritten as domain.com/forum or just something else other than domain.com/forums.

                        Could some one please help me to do that!

                        Thanks a lot!

                        PS: I actually edited my database to replace "mydomain.com/forums" with "mydomain.com" in the back-links. But I cannot do anything with the back-links from outside.

                        Comment

                        • pc1x1
                          New Member
                          • Nov 2009
                          • 8
                          • 3.8.x

                          I tried this, and it worked, but I had the double forums thing, then took it out, then it broke my links and had the 500 error, then I reverted back to default? Honestly trying to read this thread is giving me a headache, because there so many problems and each individual one, and I am not even sure if this has been updated because Matty's last edit was in Dec 09, can we please get an update, on how to make this work?

                          I installed my forums on /forums as per vb instructions, and the htaccess included in the do not upload, didn't even work period. COMON VB Support team, please clarify this for all of us.

                          All I want is to so I have

                          www.mysite.com/forums/thread title and so on so forth.

                          Thats it.

                          Comment

                          • burntire
                            Member
                            • Jun 2006
                            • 87
                            • 4.0.0

                            I still have the forums/forums problem with 4.0.3.
                            www.highperformancestangs.com

                            Comment

                            • Jaxel
                              Member
                              • Jun 2006
                              • 88

                              I still find it shocking that there is no "official" htaccess file for the built in SEO slug system.

                              Comment

                              • Jaxel
                                Member
                                • Jun 2006
                                • 88

                                Okay, this is my htaccess file as it stands now. It handles SEO slugs perfectly, and even compresses and caches images. I noticed a SIGNIFICANT boost to my forum speed with this htaccess. Content.php used to take 5 seconds to process according to microstats, now it runs in 0.9 seconds.

                                Code:
                                ## Charset
                                AddDefaultCharset Off 
                                
                                ## ETags
                                FileETag None
                                
                                ## Expires
                                <ifModule mod_expires.c>
                                	ExpiresActive On
                                	ExpiresDefault "access plus 1 seconds"
                                	ExpiresByType text/html "access plus 1 seconds"
                                	ExpiresByType image/gif "access plus 259200000 seconds"
                                	ExpiresByType image/jpeg "access plus 259200000 seconds"
                                	ExpiresByType image/png "access plus 259200000 seconds"
                                	ExpiresByType text/css "access plus 60480000 seconds"
                                	ExpiresByType text/javascript "access plus 21600000 seconds"
                                	ExpiresByType application/x-javascript "access plus 21600000 seconds"
                                </ifModule>
                                
                                ## Compression
                                <ifmodule mod_headers.c>
                                	<ifmodule mod_deflate.c>
                                		AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript
                                		BrowserMatch ^Mozilla/4 gzip-only-text/html
                                		BrowserMatch ^Mozilla/4\.0[678] no-gzip
                                		BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
                                	</ifmodule>
                                </ifmodule>
                                
                                ## Rewrites
                                RewriteEngine on
                                RewriteCond %{REQUEST_FILENAME} -s [OR]
                                RewriteCond %{REQUEST_FILENAME} -l [OR]
                                RewriteCond %{REQUEST_FILENAME} -d
                                RewriteRule ^.*$ - [NC,L]
                                
                                # Media Library
                                ReWriteRule ^media/m([0-9]+).*/tags$ media.php?do=tags_edit&mid=$1 [QSA]
                                ReWriteRule ^media/m([0-9]+).*/edit$ media.php?do=details_edit&mid=$1 [QSA]
                                ReWriteRule ^media/m([0-9]+).*/report$ media.php?do=report&mid=$1 [QSA]
                                ReWriteRule ^media/m([0-9]+).*/c([0-9]+)$ media.php?do=comment_edit&cmt=$2 [QSA]
                                ReWriteRule ^media/m([0-9]+).* media.php?do=details&mid=$1 [QSA]
                                ReWriteRule ^media/c([0-9]+).* media.php?do=category&cid=$1 [QSA]
                                ReWriteRule ^media/u([0-9]+).* media.php?do=user&uid=$1 [QSA]
                                ReWriteRule ^media/tag/(.*) media.php?do=tag&tid=$1 [QSA]
                                ReWriteRule ^media/tagcloud.* media.php?do=tag_cloud [QSA]
                                ReWriteRule ^media/search/(.*) media.php?do=search&query=$1 [QSA]
                                ReWriteRule ^media/letter/(.*) media.php?do=letter&query=$1 [QSA]
                                ReWriteRule ^media/submit.* media.php?do=submit [QSA]
                                ReWriteRule ^media/random.* media.php?do=random [QSA]
                                ReWriteRule ^media/admin/(\w+).* media.php?do=admin_$1 [QSA]
                                
                                # Forum
                                RewriteRule ^threads/.* showthread.php [QSA]
                                RewriteRule ^forums/.* forumdisplay.php [QSA]
                                RewriteRule ^members/.* member.php [QSA]
                                RewriteRule ^blogs/.* blog.php [QSA]
                                ReWriteRule ^entries/.* entry.php [QSA]
                                
                                RewriteCond %{REQUEST_FILENAME} -s [OR]
                                RewriteCond %{REQUEST_FILENAME} -l [OR]
                                RewriteCond %{REQUEST_FILENAME} -d
                                RewriteRule ^.*$ - [NC,L]
                                
                                # MVC
                                RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]

                                Comment

                                Related Topics

                                Collapse

                                Working...