Enable mod_rewrite

Untitled Document

How to Enable mod_rewrite in Apache Server

  1. Before you begin this, please make sure you make a backup copy of the original file in case you make a mistake, this way you can always go back to the original configuration - always backup before you begin doing something like this.)
  2. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines. In Fedora you can find it at /etc/httpd/ directory.)
  3. Inside the httpd.conf file find and uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line - the # sign is for comments, by removing the # sign, you are uncommenting the line)
  4. Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out. (I didnt find these in Fedora, yet my mod_rewrite works great)
  5. After you have made the changes and saved them, restart your httpd (apache) server for the changes to take affect. The easiest way to do this is to go to the shell command and type: /etc/init.d/httpd restart (this works for Fedora, might be different for other distributions!)
  6. Done

#LoadModule rewrite_module modules/mod_rewrite.so

is uncommented:
LoadModule rewrite_module modules/mod_rewrite.so

Also, if you want to enable the RewriteEngine by default, you might want to add something like
<IfModule mod_rewrite>
RewriteEngine On
</IfModule>
to the end of your httpd.conf file.

If not, make sure you specify
RewriteEngine On
somewhere in your .htaccess file.

Check to see if mod_rewrite is enabled

There are several ways to check if its working, I will try to show you the simplest method, Create a .htaccess file (a text file named .htaccess) with the following code in it

Options +FollowSymLinks
RewriteEngine On

Save the file to a subdirectory of your main site something like this

/rewrite-testfolder/.htaccess
 
Now attempt to browse to the subdirectory (http://localhost/rewrite-testfolder/). One of two things could happen

- No errors Congrats mod_rewrite engine is now enabled.
- 500, Internal Server Error If you get this message then mod_rewrite was not installed/enabled on your computer.
Now that you have your server set up correctly, you can start learning about and experimenting with the wonderful world of mod_rewrite




 

















Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "Enable mod_rewrite"

:) ) ;) ) ;;) :D ;) :p :( ( :) :( :X =(( :-o :-/ :-* :| 8-} :) ] ~x( :-t b-( :-L x( =))
Post a Comment