Issues with Rewrite Module in XAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Issues with Rewrite Module in XAMPP

Postby tinwatchman » 23. November 2010 14:58

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.
tinwatchman
 
Posts: 2
Joined: 23. November 2010 14:44

Re: Issues with Rewrite Module in XAMPP

Postby Nobbie » 23. November 2010 16:28

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
Nobbie
 
Posts: 8769
Joined: 09. March 2008 13:04

Re: Issues with Rewrite Module in XAMPP

Postby tinwatchman » 23. November 2010 16:38

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?
tinwatchman
 
Posts: 2
Joined: 23. November 2010 14:44


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests