Apache 2.2 and mod_rewrite

This is a super short (and very rough) post on how to enable mod_rewrite in Apache 2.2.

I have seen numerous posts on how to create “rewrite” scripts but found very little information on how to enable this feature in Apache 2.2.

Step 1: Uncomment the line with “mod_rewrite.so” from httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

Step 2: Search for the keyword “.htaccess” and change the AllowOverride value

AllowOverride All

Step 3: Restart Apache and check if module has been loaded (LoadedModule section in phpinfo())

Step 4: Create a test .htaccess in your root directory

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^success\.html$ index.php [L]

Step 5: Type http://localhost/success.html in your browser (change port info based on your setup)

You should be able to see your index.php load up.

Recommended book:

1590595610

Advertisements

5 Comments »

  1. Hardik said

    Hi..
    Thanks Filipino.

    AllowOverride All : this was missing point in my configuration…

    Best wishes for your http://www.slingandstonemusic.com site

    Hardik.

  2. dayg said

    You’re most welcome!

    By the way, there’s a really neat tool for generating your RewriteRules that you can play around with here.

  3. Tacyt said

    Thank You very much!

  4. Dhanushka said

    Thank you very much..really appreciate

  5. shimpy said

    I am able to understand step 2. means have i replace .htaccess to AllowOverride

RSS feed for comments on this post · TrackBack URI

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

%d bloggers like this: