Getting mod_rewrite working on PC
I have Xamp installed on my local PC. That gives me a working Apache web server that lets me test out my PHP based web sites before I publish them. This has been working great until I needed to utilize mod_rewrite. I had created a subdirectory on my local web server for a new test site. I created a .htaccess file with the necessary rewrite statements but it wasn’t working. After some Googling and testing I finally got things working. Here’s the steps:
- Need to modify the httpd.conf file for Apache. Find the line "LoadModule rewrite_module modules/mod_rewrite.so" and uncomment it (remove the # sign at the start of the line)
- Because my test site was in a sub-directory I had to change my .htaccess file just a bit from what I’ve normally had. The "RewriteBase" line needed to be "RewriteBase /test" (where "test" is the name of my subdirectory).
- The final, important step, was that I needed to add a few lines to the httpd.conf file where I had defined my sub directory.
<Directory "c:/dev/test">
Options All
AllowOverride All
</Directory>
Restart Apache and everything worked great!