Page 1 of 1

Issues with Rewrite Module in XAMPP

PostPosted: 23. November 2010 14:58
by tinwatchman
So XAMPP newbie here. Just set it up on a laptop running Windows XP/SP 3. I'm trying to figure out how to use Apache's rewrite module. I have "LoadModule rewrite_module modules/mod_rewrite.so" uncommented in http.conf; all "AllowOverride"s set to "All"; and I have the following .htaccess file saved to my htdocs folder (which is at the root of the web directory, right?):

Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/rewritetest(.*) /test$1


I have a folder named test in htdocs with a file named "hello.php." My goal here is to have requests for http://localhost/rewritetest/hello.php go to http://localhost/test/hello.php. But every time I try it - no matter what I try - I get "Object Not Found - 404 Error." Anyone know what's going on here? What am I doing wrong?

(And yes, the "LoadModule" statement in the http.conf file is defs uncommented and in play. I've triple-checked at this point.)

Thanks.

Re: Issues with Rewrite Module in XAMPP

PostPosted: 23. November 2010 16:28
by Nobbie
The pattern is wrong and never matches any file, so no substitution takes place and this all leads to Error 404.

Code: Select all
RewriteRule ^/rewritetest(.*) /test$1


The leading slash is not part of the URL-Path. Use this pattern instead:

Code: Select all
RewriteRule ^rewritetest/(.*) test/$1

Re: Issues with Rewrite Module in XAMPP

PostPosted: 23. November 2010 16:38
by tinwatchman
Great. That works. Thanks.

Just so I understand this then -- Apache filters out the website's root (in this case http://localhost/) when it parses the .htaccess file and processes the requested URL. When it gets rid of the root, it gets rid of that leading slash. And we can set what the website's root is using the RewriteBase command, right?