From:             martel at post dot pl
Operating system: Linux Gentoo
PHP version:      5.1.4
PHP Bug Type:     Apache2 related
Bug description:  $_SERVER['SCRIPT_NAME'] set incorrectly with mod_rewrite

Description:
------------
$_SERVER['SCRIPT_NAME'] is set incorrectly depending on where you place
the mod_rewrite rule. If it is placed in .htaccess, the SCRIPT_NAME is
initialized correctly but when you place the same rule in VirtualHost in
server config it is an empty string.

Not sure if it is a PHP or Apache bug but I'll start here.

The rule is:

    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1

Or (it's not relevant - both have the same result):

    RewriteEngine On
    RewriteRule !\.(js|ico|gif|jpg|png|css|swf)$ index.php

Apache2 SAPI. Apache version is 2.0.58 but I guess it may not be relevant.



Reproduce code:
---------------
// For the URL of 'http://test.nebula.intranet/archive/2006/06'. 
// File 'index.php' is located at the root of virtual host
(http://test.nebula.intranet/index.php).

var_dump($_SERVER['SCRIPT_NAME']);

Expected result:
----------------
string(10) "/index.php"

Actual result:
--------------
string(0) ""

-- 
Edit bug report at http://bugs.php.net/?id=38141&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38141&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38141&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38141&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38141&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38141&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38141&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38141&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38141&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38141&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38141&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38141&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38141&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38141&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38141&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38141&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38141&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38141&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38141&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38141&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38141&r=mysqlcfg

Reply via email to