[pmwiki-users] URL split and merge
123_dirk
123_dirk at web.de
Thu Dec 1 05:43:46 CST 2011
Hi,
i have still a problem.
the redirect is working but i can read the URL not as an clearURL.
The browser show "http://localhost/webneu/pmwiki.php?n=En.Info"
but i need "http://localhost/webneu/En/Info.html".
What is wrong in my files?
My .htaccess
#######################################################################
#######################################################################
Options -Indexes
DirectoryIndex index.php
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php43 .php4
AddType application/x-httpd-php5 .php .php5
# Use mod_rewrite to enable "Clean URLs" for a PmWiki installation.
RewriteEngine On
# Define the rewrite base.
RewriteBase /webneu
#RewriteRule (.*)\.htm $1.php
# Send requests without parameters to pmwiki.php.
RewriteRule ^$ pmwiki.php [L]
# Send requests for index.php to pmwiki.php.
RewriteRule ^index\.html$ redirect.php [L]
RewriteRule ^index\.php$ redirect.php [L]
# Send requests to pmwiki.php, appending the query string part.
RewriteRule ^([A-Z0-9\xa0-\xff].*)$ redirect.php?n=$1 [QSA,L]
#######################################################################
My redirct.php file:
<?php
$url = urldecode( $_SERVER["REQUEST_URI"] );
#echo $url;
$url = substr( $url, 0, strcspn($url,'?$&') );
$rel_s = preg_replace( '!^[a-z]+://[^/]*!i', '', $ScriptUrl );
$clean_url = strncmp( $url, $rel_s, strlen($rel_s) ) ? $url :
substr( $url, strlen($rel_s) );
$clean_url = trim( preg_replace(
'#(?:index|main)?\.(?:html?|php)$#i', '', $clean_url ), '/' );
#echo $clean_url;
# no idea how this works
# preg_match( '!([^./]*)(?:[./]([^./]*))?$!', $clean_url, $um );
#echo "$um[0] - $um[1] - $um[2] - $um[3] \n";
$ar = explode('/',$clean_url);
#echo "$ar[0] - $ar[1] - $ar[2] - $ar[3] - $ar[4] - $ar[5]\n";
# for WEB: test the ar[] array index!
if ($ar[1] != '')
{
if ($ar[2] != '')
{
if ($ar[3] != '')
{
if ($ar[4] != '')
{
$result = "$ar[1].$ar[2]$ar[3],$ar[4]";
}
else
{
$result = "$ar[1].$ar[2]$ar[3]";
}
}
else
{
$result = "$ar[1].$ar[2]";
}
}
else
{
$result = "$ar[1]";
}
}
else
{
$result = '';
}
#echo $result;
/* Redirect browser */
header("Location: http://localhost/webneu/pmwiki.php?n=$result");
#header("Location: http://localhost/webneu/pmwiki.php?n=En.Info");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
More information about the pmwiki-users
mailing list