rewrite URLs (path, extension, parameters) PHP

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
nate
Forum Newbie
Posts: 14
Joined: Tue Feb 12, 2008 6:45 pm

rewrite URLs (path, extension, parameters) PHP

Post by nate »

I would like be able to rewrite URLs,
PHP would be best,
I read there are problems with bookmarking pages with most other techniques, such as frames etc -- (http://classicasp.aspfaq.com/general/ho ... ation.html) -- . I am doing this for usability sake and not for security.

For example, I would like to turn these

http://domain.com/folderA/a/b/file_1.php?text?moreText
http://domain.com/anotherFolder/file_2.php?otherText?1
http://domain.com/thisFolder/subFolder/ ... therText?2

into these

http://domain.com/standardFolder/file_1
http://domain.com/standardFolder/file_2
http://domain.com/standardFolder/file_3

the path needs to change, and the file extension and URL parameters need to be removed; while maintaining the functionality of passing variables through the URL (of course)

Thanx,
Nate
earcaraxe
Forum Newbie
Posts: 5
Joined: Mon Apr 07, 2008 8:33 pm

Re: rewrite URLs (path, extension, parameters) PHP

Post by earcaraxe »

To be honest, I don't think that PHP is the best way to do this. Mod Rewrite in apache is really your best bet for doing this cleanly and easily. I don't know of any way to do it in PHP that doesn't seem like a clumsy hack. Someone else might have some ideas, but I'd definitely push you towards setting up Mod Rewrite.
nate
Forum Newbie
Posts: 14
Joined: Tue Feb 12, 2008 6:45 pm

Re: rewrite URLs (path, extension, parameters) PHP

Post by nate »

Thanks for the response, I will look into Mod Rewrite and post here how it goes, I may not have access to server configurations I haven't gotten that far yet. I too loathe clumsy hacks :)
Nate
nate
Forum Newbie
Posts: 14
Joined: Tue Feb 12, 2008 6:45 pm

Re: rewrite URLs (path, extension, parameters) PHP

Post by nate »

My host doesn't support Mod Rewrite, so the new host, soon, will give me cause to post back here how that goes. Thanks for the reply, keep em coming. ;)
Nate
Post Reply