How to turn on the short URLs function (using mod_rewrite)

First off, you need to make sure that you are running on an Apache web server with mod_rewrite capabilities. There are quite likely other ways to create a system of shortened URL rules, but the method we use and support takes advantage of the mod_rewrite library by Apache. If you do not have this installed already, do so now.

1) CREATE THE .htaccess FILE

In Apache, the .htaccess file is a special configuration file to allow for settings on a virtual-user basis; that is why it is so commonly used by hosting providers as it allows each client on a server to tweak Apache to their preference. Any instructions put into this file are processed and handled before any request to the documents in the same directory as the .htaccess file and all of it’s sub-directories. It is important to be aware of this because any invalid syntax that you put into a .htaccess file can completely cripple your web site by returning an “Invalid Server Configuration” error.

The file should be called “.htaccess” (without the quotation marks and with a leading dot - note: this can vary if you specifically altered Apache’s master configuration to use a different file name instead).

Place the following code, between the line of hash marks, into a plain text file and save it as “.htaccess”:

##### PHPFOX SHORT URL INSTRUCTIONS #####

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/file/.*
RewriteCond %{REQUEST_URI} !^/install/.*
RewriteCond %{REQUEST_URI} !^/update/.*
RewriteCond %{REQUEST_URI} !^/design/.*
RewriteCond %{REQUEST_URI} !^/plugins/.*
RewriteCond %{REQUEST_URI} !^/vbforum/.*
RewriteRule ^index.php(/.*)$ /index.php?do=$1 [L]

RewriteCond %{REQUEST_URI} !^/file/.*
RewriteCond %{REQUEST_URI} !^/install/.*
RewriteCond %{REQUEST_URI} !^/update/.*
RewriteCond %{REQUEST_URI} !^/design/.*
RewriteCond %{REQUEST_URI} !^/plugins/.*
RewriteCond %{REQUEST_URI} !^/vbforum/.*
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php?do=/$1 [L]

##### PHPFOX SHORT URL INSTRUCTIONS #####

Make sure that when you save the file it is named simply “.htaccess” and that nothing is before the dot and nothing is after the file name (such as “.htaccess.txt”

Leave a Reply

You must be logged in to post a comment.