clean url

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
mainegate
Forum Newbie
Posts: 14
Joined: Sat Nov 29, 2008 5:49 pm

clean url

Post by mainegate »

I have read postings that to get a clean url you need to use mod rewrite. I have tried and I'm not getting it. I'm trying to have someone be able to enter http://localhost/video.php?id=1234 and http://localhost/video/1234 is displayed in the browser. Anyone have any idea?

I know I could if a file doesn't have an extention then have it by default be a php file. But from what I read it is always best to have the .php on every php file. Right?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: clean url

Post by Eran »

The best practice (in my opinion) is to use a pattern called Front Controller. A front controller provides a single entry point into your application, and then determines which script to actually use/include. This is called a dispatch process.
Read the following article on the zend devzone for more details - http://devzone.zend.com/node/view/id/70
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: clean url

Post by jmut »

mainegate wrote:I have read postings that to get a clean url you need to use mod rewrite. I have tried and I'm not getting it. I'm trying to have someone be able to enter http://localhost/video.php?id=1234 and http://localhost/video/1234 is displayed in the browser. Anyone have any idea?

I know I could if a file doesn't have an extention then have it by default be a php file. But from what I read it is always best to have the .php on every php file. Right?
I think you understand it wrong. In browser you see whatever you type....so approach is you type http://localhost/video/1234 and then modrewrite will either transform to http://localhost/video.php?id=1234 or you'll use some router objects like pytrin suggest that will parse the url for you.
Post Reply