test mod_rewrite in apache

Make sure your httpd.conf includes:
.
.
LoadModule rewrite_module
.
.

AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On

Next, edit .htaccess in /rewritedirectory and add
RewriteEngine On
RewriteRule
eg: ^link([^/]*).html$ rewrite.php?link=$1

To test if its working properly:

Edit test_rewrite.php in /rewritedirectory

<?php
switch($_GET['link'])
{
case 1: echo 'no mod_rewrite';break;
case 2: echo 'mod_rewrite';break;
default: echo 'mod_rewrite test';break;
}
echo 'test mod_rewrite‘;
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s