Rewrite issue


I have an issue regarding a rewrite rule.
It looks like this:

RewriteEngine on
RewriteBase /photo/www/

RewriteRule ^$ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php?$1 [L,QSA]

I have the URI:

The weird fact is that, after a simple var_dump($_GET), my request will look like this:

array (size=2)
  'uploads/photos/2014-01/m/resize/52d9ac4497aa1_DSC_4609_jpg' => string '' (length=0)
  'test' => string '3' (length=1)

If you did not notice, why do I get “_” (underline) instead of “.” (dot)

52d9ac4497aa1_DSC_4609_jpg vs

I tried to replace some name and made it
“52d9ac4497559_DSC.0923.jpg” and the result is

Is there a reason for this “rewrite dots with underlines”?

It is not the rewrite mechanism that changes the dots to underscores but PHP. PHP simply regards dot as an invalid variable name and that’s why it doesn’t allow it. Sure, currently you can have dots as array keys so technically you could have them in $_GET arrays but I suppose we are seeing legacy behaviour here - in the past when register_globals was standard practice all GET variables automatically became available as global variables and in such cases you couldn’t have dots in their names.

Have a look at what $_SERVER[‘QUERY_STRING’] holds - you might have more luck with it :slight_smile:

Oh yea…
I missed the register_globals “feature”.

I never rely on $_SERVER - it’s one of my dev-habits :slight_smile:
So I’ll just parse my filenames as I need to.

Thanks a lot!