FeaturePrettyUrlsExtended

Use of URL rewriting (mod_rewrite) to generate cleaner site URL's

Created by: James Thompson, Last modification: 30 Jun 2008 (09:17 UTC) by Kozuch
This feature is an extension of PrettyUrls. It adds an extra tag into the URLs to make them unambigious. Some links generated by PrettyUrls may not function as expected. For example, a link to the user page for the user 'admin' will not display correctly when PrettyUrls is enabled.

For User and Wiki links, this feature adds a '/view' tag into the generated URLs.

Normal URL:

http://www.bitweaver.org/wiki/index.php?page=LDAPCompatibility


When PrettyUrls is enabled:

http://www.bitweaver.org/wiki/LDAPCompatibility


When FeaturePrettyUrlsExtended is enabled:

http://www.bitweaver.org/wiki/view/LDAPCompatibility


Enabling this feature will require manually editing the default .htaccess files.

The exact changes will depend on your web server configuration.

Example for wiki/.htaccess

<IfModule mod_rewrite.c>
        RewriteEngine  on
        RewriteBase /wiki/
        RewriteCond %{SCRIPT_FILENAME}        -f [OR]
        RewriteCond %{SCRIPT_FILENAME}/index.php        -f
        RewriteRule ^(.*)$        - [L]
        RewriteRule view/(.*)$        index.php?page=$1  [L]
</IfModule>


Or, you can incorporate all the necessary rewrites into your main Apache configuration:

<IfModule mod_rewrite.c>
        RewriteEngine  on
        #RewriteLog /var/log/httpd/rewrite.log
        #RewriteLogLevel 2

        # If the URL points to a file that exists, don't rewrite.
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}            -f [OR]
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}/index.php  -f [OR]
        RewriteCond %{REQUEST_FILENAME}                            -f [OR]
        RewriteCond %{REQUEST_FILENAME}/index.php                  -f
        RewriteRule ^.*$                                           - [L]

        RewriteRule ^/fisheye/image/([0-9]+)(/[0-9/]+)*/?([A-Za-z]+)*$    /fisheye/view_image.php?image_id=$1&gallery_path=$2&size=$3  [L,QSA]
        RewriteRule ^/fisheye/gallery([0-9/]+)*/([0-9]+)/?$               /fisheye/view.php?gallery_id=$2&gallery_path=$1  [L,QSA]
        RewriteRule ^/users/view/([A-Za-z0-9_]+.*)$                       /users/index.php?home=$1 [L,QSA]
        RewriteRule ^/users/([A-Za-z0-9_]+.*)$                            /users/index.php?home=$1 [L,QSA]
        RewriteRule ^/wiki/view/(.+)$                                     /wiki/index.php?page=$1  [L]
        RewriteRule ^/wiki/(.+)$                                          /wiki/index.php?page=$1  [L]
        RewriteRule ^/articles/([0-9]+.*)$                                /articles/read.php?article_id=$1  [L]
        RewriteRule ^/blogs/view/content/([0-9]+.*)$                      /blogs/view_post.php?content_id=$1  [L]
        RewriteRule ^/blogs/post/([0-9]+.*)$                              /blogs/view_post.php?post_id=$1  [L]
        RewriteRule ^/blogs/([0-9]+.*)$                                   /blogs/view.php?blog_id=$1  [L]
        RewriteRule ^/pigeonholes/(.+)$                                   /pigeonholes/index.php?content_id=$1  [L]

        # Defend against possible future exploits: http://www.phpbb.com/phpBB/viewtopic.php?t=308605 and http://www.phpbb.com/phpBB/viewtopic.php?p=1368328#1368328
        RewriteCond %{QUERY_STRING} ^(.*)\.printf\(        [OR]
        RewriteCond %{QUERY_STRING} ^(.*)wget\%20          [OR]
        RewriteCond %{QUERY_STRING} ^(.*)echr(.*)          [OR]
        RewriteCond %{QUERY_STRING} ^(.*)esystem(.*)       [OR]
        RewriteCond %{QUERY_STRING} ^(.*)highlight=\%2527  [OR]
        RewriteCond %{QUERY_STRING} ^(.*)highlight='       [OR]
        RewriteCond %{HTTP_COOKIE}% s:(.*):\%22test1\%22\%3b
        RewriteRule ^.*$ http://127.0.0.1/ [L,F]

        RewriteCond %{HTTP_REFERER} (texas\-hold\-em|e\-site|viagra|casino|poker|holdem|pharmacy|e\-buy|cialis|pills)(.*)\.(com|net|org|us|info|biz)   [NC,OR]
        RewriteCond %{HTTP_REFERER} \.(com|net|org|us|info|biz)\/(online\-poker|texas-holdem|poker|empire\-poker|poker\-rooms)\.html$     [NC,OR]
        RewriteCond %{HTTP_REFERER} ^http://www.andrewsaluk.com/.*$  [NC,OR]
        RewriteCond %{HTTP_REFERER} \.(com|net|org|us|info|biz)\/.*(equity|mortgage|consolidation|loan).*\.html$  [NC]
        RewriteRule ^.*$ http://127.0.0.1/ [L,F]

        # fake out phpBB user profile page
        RewriteCond %{REQUEST_URI} profile.php
        RewriteCond %{QUERY_STRING} .*mode=viewprofile.*u=([0-9]*)
        RewriteRule .*  /users/index.php?fHomepage=%1 [R,env=VV_THEME:people,QSA]
</IfModule>


See Also



Related Items

Features

  •    •    •    •    •    •    •    •    •    •    •    •  Anonymous  •  Anonymous

Online Help

These pages are linked from within bitweaver's administration

  •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •    •  Anonymous  •  Anonymous  •  Anonymous  •  Array  •  Array

Comments

Debt counseling

by Christian Debt Solutions, 18 Aug 2008 (04:32 UTC)