How to use Mod Rewrite

From Blahdocs Wiki

Jump to: navigation, search

What is mod_rewrite

Using mod_rewrite on your forum is a very useful feature. It is a way to change your address to your forum from the traditional www.yoursite.com/cgi-bin/forum/Blah.pl to a cleaner address shown below. It has also been said that this will increase the number of pages on your forum indexed by search engines.
http://www.yoursite.com/forum/


Step 1 - Create a .htaccess file and upload it

Create a file with your text editor and name it .htaccess, and place the following code in it.

Options All Indexes
IndexOptions FancyIndexing
RewriteEngine On
RewriteBase /forum/
RewriteRule ^(.*) /cgi-bin/forum/Blah.pl?$1

After you have created your .htaccess file, create a folder named forum in the root web directory on your web server, CHMOD it to 755, and upload your .htaccess file to this folder.

NOTE: IndexOptions FancyIndexing (shown above) can cause problems on some servers. If you have problems with mod rewrite, and all your settings are correct, you should delete this line from the .htaccess file.


Step 2 - Edit Blah.pl

Edit Blah.pl and change the following lines from:

# Filename information
$scriptname = $scriptname || 'Blah.pl'; # Change name of Blah.pl
$modrewrite = $modrewrite || '?';       # Setting, mod_rewrite: on = '' | off = '?'

to this:

# Filename information
$scriptname = $scriptname || '/forum/'; # Change name of Blah.pl
$modrewrite = $modrewrite || '';       # Setting, mod_rewrite: on = '' | off = '?'

NOTE: These lines may look different depending on which version of E-Blah you are using. This example is from version 10.2.5.


Step 3 - Edit settings in your Admin Control Panel

Go to your Admin Control Panel | Forum Settings | Directories and Web Addresses and change your Forum Address: setting to this and save your settings.

http://www.yoursite.com/

NOTE: Where it says yoursite.com above, you should type in your actual web address for your site.

Now Mod Rewrite is enabled for your forum, and you should be able to go to www.yoursite.com/forum/ to view it. Remember, if you upgrade your forum, you will need to edit your Blah.pl file and change the $scriptname and $modrewrite lines to enable mod_rewrite again.


If you would like additional information about mod_rewrite click here.

Personal tools
Downloads