Forum Moderators: coopster
RewriteRule ^/foo/(\d{4})/(\d{1,2})/?$ /foo?year=$1&month=$2
However, when I refer to $_SERVER['SCRIPT_NAME'] I get the URI, as it appears to the user, eg. "foo/2006/5", which doesn't really exist. However, $_SERVER['SCRIPT_FILENAME'] will always show the right script name, eg. "/foo" BUT it prepends the document root. So, it seems like functionally SCRIPT_NAME is the same as REQUEST_URI, whereas I'd like it to be inbetween REQUEST_URI and SCRIPT_FILENAME: showing the actual script that's executing, but without the document root.
Right now I'm working around it by just using SCRIPT_FILENAME and doing a str_replace() to remove the DOCUMENT_ROOT. But that seems suboptimal and potentially buggy; the real issue here is that SCRIPT_NAME isn't yielding what I'd expect from the PHP docs. Is there something I'm missing? Does anyone know of another $_SERVER variable that accomplishes what I'm looking for.
I'm not sure, but...will this work?:
$name = ".".$_SERVER['SCRIPT_NAME'];
Hope this helps...and if not you can blame it on my lack of sleep :)
eelix
$page = substr('$_SERVER[SCRIPT_NAME]', 1);
Next time i won't write random things that have nothing to do with your problem :)
eelix
preg_replace('/\/*/', '', $_SERVER['SCRIPT_NAME']);
str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']);
Thanks anyhow.