Announcement

Collapse
No announcement yet.

Mod Rewrite Friendly URLs => .htaccess

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

  • Miguel Montano
    replied
    Thanks for your work, I'll try it

    Leave a comment:


  • Steve Machol
    replied
    The current .htaccess files in the vB zip file do work for the majority of situations. If you wish to discuss this custom .htaccess file (which by the way caused white pages on my vB4 test forum) please do so over at the vB mod site.: www.vbulletin.org

    Leave a comment:


  • mykes
    replied
    Code:
    		AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript
    Should be:

    Code:
    		AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript application/javascript
    None of the javascripts sent by my server were being gzip encoded.


    Originally posted by Jaxel View Post
    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]

    Leave a comment:


  • Jaxel
    replied
    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]

    Leave a comment:


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

    Leave a comment:


  • burntire
    replied
    I still have the forums/forums problem with 4.0.3.

    Leave a comment:


  • pc1x1
    replied
    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.

    Leave a comment:


  • cvn
    replied
    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.

    Leave a comment:


  • Jaxel
    replied
    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]

    Leave a comment:


  • obmob
    replied
    Originally posted by thanhdat View Post
    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 ^^,

    Leave a comment:


  • thanhdat
    replied
    Should I have buy vBSEO?

    Leave a comment:


  • Oracle simsim
    replied
    Thank you I tested that and work great, but because my forum is Arabic, I can't use any type of friendly SEO url

    Leave a comment:


  • Bacon Butty
    replied
    Should what I've asked above be asked on vbSEO?

    Leave a comment:


  • Bacon Butty
    replied
    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!

    Leave a comment:


  • Jaxel
    replied
    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.

    Leave a comment:

Related Topics

Collapse

Working...
X