Web Hosting Talk







View Full Version : .htaccess string replace


Dumb Genius
05-07-2005, 04:43 AM
I would like to change my & by & for my URLs, how can I do that by using .htaccess as I dont have direct access to the php.ini?

Thanks,
DG

programmingpros
05-15-2005, 07:20 AM
I am not sure if I understand you correctly.

This will replace [& and =] ---> /

Just using PHP - something like this:


$base_url = 'http:||localhost/xxxxxxxxx/index.php'; //Edit this to suit

$redirect = "";

if ( $_SERVER['PATH_INFO'] != "" )
{
$c = 0;

foreach( explode( "/", $_SERVER['PATH_INFO'] ) as $bit)
{
if ($bit != "")
{
if ($c == 0)
{
$c++;
$redirect .= $bit.'=';
}
else
{
$c = 0;
$redirect .= $bit.'&';
}
}
}
}

header("Location: $base_url?".$redirect);
exit();