Page 1 of 1

rewrite URLs (path, extension, parameters) PHP

Posted: Tue Apr 08, 2008 7:13 pm
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

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

Posted: Tue Apr 08, 2008 7:29 pm
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.

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

Posted: Wed Apr 09, 2008 11:59 am
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

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

Posted: Sun Apr 27, 2008 1:41 am
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