Jump to content

URL Parameters using / instead of ?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
linuxprogramming4ever

linuxprogramming4ever

    Newbie

  • Members
  • PipPip
  • 10 posts
I have the faint remembrance that it was possible in PHP to replace the usual ? URL paramenters by one that used / instead.
Like for example replace:

<website>/view.php?id=345

by

<website>/view.php/345 or <website>/view.php/id/345

Is this possible and how?

If not, can this be accomplished with apache's mod_rewrite?

#2
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
PHP alone cannot rewrite URL's but if you use apache's mod_rewrite PHP can get the url parameters back.

#3
linuxprogramming4ever

linuxprogramming4ever

    Newbie

  • Members
  • PipPip
  • 10 posts
Thanks, got it to work with mod_rewrite.

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts

BlaineSch said:

PHP alone cannot rewrite URL's but if you use apache's mod_rewrite PHP can get the url parameters back.

Don't be so naive young grasshopper. SEF URLs with out mod_rewrite | John Ciacia

#5
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts

John said:

Don't be so naive young grasshopper. SEF URLs with out mod_rewrite | John Ciacia

How would you setup the server to accept the url though? Yes you can parse through a address easily but if you don't have a mod_rewrite or something else, won't you get a 404 error for anything that is already not a file? How do you set that up on the server end?

#6
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
You set the server up to do nothing - the php file exists, so the server will load that, there is no 404 error.

#7
Guest_Jaan_*

Guest_Jaan_*
  • Guests
Young grasshopper hahahahahaha.. lol pwned

but umm.. I learned something today ^^ thanks John..