Jump to content

Recommended Posts

You should be able to break apart the URL with explode():

 

//GET THE CURRENT URL
$url = $_SERVER['PHP_SELF'];

//BREAK APART THE URL
$urlPieces = explode('/', $url);

//LOOP THROUGH THE URL PIECES
foreach($urlPieces as $currPiece) {
    echo "<li>$currPiece</li>";
}

 

 

You'll need to replace the echo statement in the foreach loop with whatever formatting you need to get the search query. Then just redirect the page.

Thanks for your kind assistance. My problem is that

$url = $_SERVER['PHP_SELF'];

considers the error page at "http://mysite.com/404.php" instead of the misspelled url.

 

For example, if someone write "http://mysite.com/something-wrong.html",

$url = $_SERVER['PHP_SELF'];
echo $url;

will show "http://mysite.com/404.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.