Apache Mod_Rewrite is erroneously changing case

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

Apache Mod_Rewrite is erroneously changing case

Postby Klupamos » 10. January 2016 07:38

I have the following rule in my root .htaccess file

Code: Select all
RewriteRule ^((?:Paired|Mobile)?Coupon|Raffle)/(\d+)/Image/?$       /product_image.php?type=$1&id=$2    [L,NC]

and the following code in /product_image.php

Code: Select all
var_dump([
        "REQUEST_URI" =>$_SERVER["REQUEST_URI"],
        "QUERY_STRING" =>$_SERVER["QUERY_STRING"]
]);

When I request /Coupon/9/Image/ I get

Code: Select all
array(2) {
    ["REQUEST_URI"] => string(16) "/Coupon/9/Image/"
    ["QUERY_STRING"] => string(16) "type=Coupon&id=9"
}

When I request /Raffle/2/Image/ I get

Code: Select all
array(2) {
    ["REQUEST_URI"] => string(15) "/Raffle/2/Image/" 
    ["QUERY_STRING"] => string(16) "type=raffle&id=2"
}

The raffle request query_string is always lowercase, While cases in the coupon request are mirrored in the query_string. How do I ensure the request case is preserved in the query_string?

My debugging before asking here:
    * Removing the [No Case] flag causes a 404 error for the raffle request (case independent); the coupon request only matches for 'Coupon' as expected.
    * This is not an issue on my production server (standard LAMP install - No XAMPP)





XAMPP version
    5.5.30
operating system version
    Windows 10 x64
XAMPP installation path
    S:\Production\Networking\xampp
configuration changes
    enabled mod_rewrite
    I also set up Virtual hosts, but don't think it affects my issue.
Klupamos
 
Posts: 2
Joined: 10. January 2016 07:24
Operating System: Windows 10 x64

Re: Apache Mod_Rewrite is erroneously changing case

Postby Nobbie » 10. January 2016 12:09

Ist there a /raffle folder in your DocumentRoot of Xampp? And maybe also a /Coupon folder? Apache probably checks against existing folders before executing the Rewrite and maybe then the input URL is set to the real folder name. Only a guess.
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: Apache Mod_Rewrite is erroneously changing case

Postby Klupamos » 10. January 2016 12:26

You are absolutely correct. I can't believe I didn't check for that. I renamed my /raffle folder and it is working as expected. Thank you.

Although Apache looking for /Raffle/2/Image in /raffle is a little confusing.
Klupamos
 
Posts: 2
Joined: 10. January 2016 07:24
Operating System: Windows 10 x64

Re: Apache Mod_Rewrite is erroneously changing case

Postby Nobbie » 10. January 2016 13:01

Klupamos wrote:Although Apache looking for /Raffle/2/Image in /raffle is a little confusing.


I think that is due to the NC flag. Or it might be for compatibility reasons, as windows folders and filenames havent been case-sensitive for a long time. This also depends on the filesystem (ntfs, fat32, fat16 etc.).

mod_rewrite is a rather complex thing and i had in mind that (sometimes) it is hard to understand, in which order folders and URLs are matched to the patterns etc.
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 52 guests