Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

take keywords from url, use them on page



1:28 am on Jul 4, 2007 (gmt 0)

10+ Year Member

how can i do the following...

user types in my www.mydomain.com/anywordhere

how can i echo the 'anywordhere' onto the page?



2:16 am on Jul 4, 2007 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld, invisible777.

You should be able to parse out the pieces you need from one of PHP's $_SERVER [php.net]superglobal variables.


2:43 am on Jul 4, 2007 (gmt 0)

10+ Year Member

Hi, thanks for the reply. I have this piece of code:

$keys = explode("-",str_replace(array("http://",".php"),"",$_SERVER['SCRIPT_URI']));
echo $keys[0]."<br>".$keys[1];?>

which requires the page exist... whereas i just need something that allows the user to type in www.mydomain.com/absolutelyanythinghere and then i suppose to be redirected to an index.php where 'absolutelyanythinghere' can be echoed onto the page...


1:46 pm on Jul 4, 2007 (gmt 0)

10+ Year Member

you can pass that string to index.php as parameter

redirect www.example.net/index.php?invalidpage=absolutelyanythinghere

and then in index.php
use get to get paremeter

$string = $_GET['invalidpage'];

then display value of the variable
echo $string;


3:39 pm on Jul 4, 2007 (gmt 0)

10+ Year Member

sorry im not following... how does that redirect occur if the original invalid page does not exist?


7:02 pm on Jul 4, 2007 (gmt 0)

5+ Year Member

You need to add the following code to your .htaccess file.

RewriteEngine on
RewriteRule ^([^/]+)$ /index.php?invalidpage=$1 [L]

And your index.php will be

print $_GET['invalidpage'];



Featured Threads

Hot Threads This Week

Hot Threads This Month