homepage Welcome to WebmasterWorld Guest from 54.234.2.88
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
take keywords from url, use them on page
invisible777




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

how can i do the following...

user types in my www.mydomain.com/anywordhere

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

thanks!

 

coopster




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

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.

invisible777




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

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

<?PHP
$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...

Mohamed




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

you can pass that string to index.php as parameter

e.g
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;

invisible777




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

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

milanmk




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

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'];

Milan

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved