You are here: Re: redirect.php maligns redirection URL every time « PHP Programming Language « IT news, forums, messages
Re: redirect.php maligns redirection URL every time

Posted by Shaun on 10/28/06 02:12

On 26 Oct 2006 10:33:23 -0700, "comp.lang.php"
<phillip.s.powell@gmail.com> wrote:

> $url = $redirectArray[$id]['attributes']['URL'];
> if (trim($redirectArray[$id]['attributes']['QUERY_STRING']) !== '?')
>$url .= '?';
> $url .= preg_replace('/&#061;/i', '=',
>$redirectArray[$id]['attributes']['QUERY_STRING']);
> $url = preg_replace('/\/$/', '', $url); // REMOVE TRAILING / TO
>ACCOMMODATE QUERY STRING AND/OR ANCHOR
>
>If the URL happens to be this:
>
>http://the-nordic-one.livejournal.com#alchemymemory10242006
>
>Instead it winds up looking like this every single time:
>
>http://the-nordic-one.livejournal.com/#alchemymemory10242006?

It appears that the code is missing a set of curly braces; this is
causing the first call to preg_match() to fire unconditionally, which
means that the query string is always going to be appended to the URL
(even if it's only '?').

Try this:

$url = $redirectArray[$id]['attributes']['URL'];
if (trim($redirectArray[$id]['attributes']['QUERY_STRING']) !== '?') {
$url .= '?';
$url .= preg_replace('/&#061;/i', '=',
$redirectArray[$id]['attributes']['QUERY_STRING']);
}
$url = preg_replace('/\/$/', '', $url); // REMOVE TRAILING /

hth

-
Remove mypants to email.
<http://www.shaunc.com/>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация