PITS /
00965: Clean URLs & Apache MultiViews/Alias issue
Summary: Clean URLs & Apache MultiViews/Alias issue
Created: 2007-08-09 08:25
Status: Open
Category: Bug
From: julien /dot/ charbon /at/ gmail /dot/ com, Dfaure
Assigned:
Priority: 52
Version: 2.2.0-beta63
OS: Apache 2.2.3 & Php 5.2.0
Description: Hi, I configure pmwiki to get clean URLs using Apache MultiViews as defined in:
Wrapper using Apache MultiViews
And I guess I find a bug. You have in pmwiki.php:296:
$pagename= @$_REQUEST['n']; if (!$pagename)$pagename= @$_REQUEST['pagename']; if (!$pagename&& preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!', $_SERVER['REQUEST_URI'],$match))$pagename= urldecode($match[1]);
Or with clean URLs using Apache MultiViews configuration on a request on :
http://host/wiki/Group/Page
you have
$_SERVER['SCRIPT_NAME'] is equal to "wiki.php" $_SERVER['REQUEST_URI'] is equal to /wiki/Group/Page
thus:
preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
$_SERVER['REQUEST_URI'],$match))
failed and I get an empty pagename value.
Below a patch a correct this issue for me. This not the final correction but this patch show precisely where is the issue.
I had the same kind of issue (ie. inconsistency between $_SERVER['SCRIPT_NAME'] and $_SERVER['REQUEST_URI']) in the following config:
- Win32,
- Apache 2.2.4,
- Php 4.4.7 as CGI (with cgi.fix_pathinfo=1),
- Apache location defined with an url alias different from the directory name used:
Alias /~dev "C:/hosted/pmwiki-dev"
<Directory "C:/hosted/pmwiki-dev">
AddType application/x-httpd-php4 .php
...
</Directory>
In this case:
['SCRIPT_NAME'] => /pmwiki-dev/pmwiki.php ['REQUEST_URI'] => /~dev/pmwiki.php/Group/Page
And I manage to solve it with the following code in config.php:
if (!$pagename
&& (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === false)
&& preg_match('!^'.preg_quote(str_replace($_SERVER['PATH_INFO'], '',
$_SERVER['REQUEST_URI']),'!')
.'/?([^?]*)!',
$_SERVER['REQUEST_URI'],$match))
$pagename = urldecode($match[1]);
Dfaure October 04, 2007, at 09:50 AM