How to enable mod_rewrite in Apache
Sunday, June 22nd, 2008To enable the rewrite module in Apache you will need access to the httpd.conf file, located in {Apache folder}/conf/httpd.conf
Open up the file, and search for
#LoadModule rewrite_module modules/mod_rewrite.so
and simply remove the # from the start of the line. Then save the file, and restart the Apache server. You should now be able to use the mod_rewrite functionality on your server. to test this, create a new file called test.php in your root html folder, with the following code in it
1 2 3 4 5 6 7 8 | <?php if(isset($_GET['p'])) { echo 'ENABLED! Phrase you entered: ' . $_GET['p']; }else{ echo 'MOD_REWRITE IS DISABLED!'; } ?> |
and put
1 2 3 | RewriteEngine On RewriteBase / RewriteRule ^test/(.+)$ test.php?p=$1 [L] |
into a .htaccess file in the same folder
Don’t forget to delete these two files after testing