1

I have a number of pages that use $_GET but there is only ever 1 ID.

For example /view/document/id=1 so I use $_GET['id'] which is 1.

Is it possible to do /view/document/1 and if so what would the $_GET be?

I did try searching online but all I could find was information on sessions for some reason!

Thanks

user3973427
  • 1,435
  • 3
  • 16
  • 20

3 Answers3

3

You would use GET the same way, but you'll have to modify routing to match the url... See tutorials to get an idea, because it's a kinda broader topic, for instance here:

http://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049
Routing php query using .htaccess

Etc. Just search for url routing or url rewriting if these links ever stop being available.

You'll just have to specify few rewrite rules and you're good to go.

If you use some framework later, these tend to do some stuff for you, but you'll have to specify some rules for routing anyway, so it's a good idea to understand the basics with .htaccess first.

Community
  • 1
  • 1
walther
  • 13,466
  • 5
  • 41
  • 67
1

if you use mvc frameworks like codeigniter or cakephp or yii then its possible easily. on the other hand you can try with .htaccess, I hope it will solve your problem.

0

Have a look into .htaccess rewrite. With that you can change the displayed URL without changing the $_GET['id']

Felix
  • 541
  • 1
  • 4
  • 14