#24520 [Bgs]: Rewriting an URL with mod_rewrite does not register variables properly.

From: Date: Tue, 08 Jul 2003 08:36:52 +0000
Subject: #24520 [Bgs]: Rewriting an URL with mod_rewrite does not register variables properly.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43422@lists.php.net to get a copy of this message
ID: 24520 User updated by: kouber@php.net Reported By: kouber@php.net Status: Bogus Bug Type: Apache related Operating System: Win2000 NT PHP Version: 4.3.3RC2-dev New Comment: Nobody's fault, but mine. Sorry. Previous Comments: ------------------------------------------------------------------------ [2003-07-07 11:01:30] sniper@php.net Works fine here with these settings: <VirtualHost *> ServerName localhost RewriteEngine on RewriteRule ([a-z]+)?/?([0-9]+) /rewrite.php?job_sid=$2&theme=$1 DocumentRoot /www/apache/htdocs/ php_value register_globals 1 </VirtualHost> You propably just have something wrong with your settings. ------------------------------------------------------------------------ [2003-07-07 10:04:17] kouber@php.net Same behaviour. ------------------------------------------------------------------------ [2003-07-07 05:42:45] sniper@php.net Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip ------------------------------------------------------------------------ [2003-07-07 05:35:46] kouber@php.net The actual RewriteRule is: RewriteRule ([a-z]+)?/?([0-9]+) job_view.php?job_sid=$2&theme=$1 which excludes the slash (/) from the $theme variable. As described, theme should be string(5) "gray/". ------------------------------------------------------------------------ [2003-07-07 05:27:50] kouber@php.net Description: ------------ When I write some RewriteRule with additional "redirected" variables, they seem to be empty in my script. RewriteRule ([a-z]+/)?([0-9]+) job_view.php?job_sid=$2&theme=$1 When I call the following URL "http://localhost/gray/56", I expect in my script to have these variables: job_sid => string(2) "56" theme => string(4) "gray" But what var_dump($job_sid) and var_dump($theme) actually tells me is: job_sid => string(2) "56" theme => string(0) "" Note that $theme is an empty string, but not null. The weirdest thing is that var_dump($_GET) shows correct result: array(2) { ["job_sid"]=> string(2) "56" ["theme"]=> string(4) "gray" } I forgot to mention, that I have register_globals=On, so I expect ALL of my $_GET variables to be registered as globals. Reproduce code: --------------- var_dump($_GET); var_dump($job_sid); var_dump($theme); Expected result: ---------------- array(2) { ["job_sid"]=> string(2) "56" ["theme"]=> string(4) "gray" } string(2) "56" string(4) "gray" Actual result: -------------- array(2) { ["job_sid"]=> string(2) "56" ["theme"]=> string(4) "gray" } string(2) "56" string(0) "" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24520&edit=1

« previous php.bugs (#43422) next »