Question about page.php/wordgoeshere

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Question about page.php/wordgoeshere

Post by Mr Tech »

Hey there,

I've seen pages that have a URL like: http://www.devpapers.com/view_author.php/39

See how they have a /39 after the file name? I'm presuming that ti works the same way as: http://www.devpapers.com/view_author.php?39

How do I get the PHP to read the text after the /?

Thanks
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

you can use apache mod_rewrite for that
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Google for mod_rewrite.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

[google]path_info[/google]

You can emulate path_info feature via mod_rewrite, but generally there's no need to.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

Code: Select all

// given the url  http://www.devpapers.com/view_author.php/39/foo/bar

echo getenv('PATH_INFO'); // outputs: /39/foo/bar

the reason thr url still works is because apache will keep seeking for existing filenames in the given url,
first it checks for a file named "bar"
if not found, then it seeks for "foo"
then if not found, it looks for "39"
then, if not found, it looks for "view_author.php" , which it finds. so the PATH_INFO envionment variable will be set based upon the currently executing script
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

Thanks rehfeld,

That helped a lto :)
Post Reply