-1

I am fully versed in how to get, and clean the vars in a $_GET and $_POST, and I understand that $_REQUEST listens for both GET and POST's.

I understand that the GET is www.somesite.com?GET=MYVAR, but my question is this. Can you take: www.somesite.com/MYVAR and put the subpage into a var, as apposed to using the ?GET=MYVAR

In PHP

Thanks,

semirturgay
  • 4,151
  • 3
  • 30
  • 50
Ypsilon
  • 33
  • 7

4 Answers4

0

Assuming you're using Apache, you would use the mod_rewrite module with an .htaccess file. There are tons of tutorials you can find via Google once you know the right words :)

Jessica
  • 7,075
  • 28
  • 39
0

Yes, but this is actually less dependent on PHP and more dependent on your webserver. It's called rewriting URLs. If you're using Apache, it's mod_rewrite you'll need to look into.

Here's an example for nginx using a rewrite rule:

rewrite ^([^/]+)(/)?$ /index.php?var=$1;

Then you'll be able to access it using

$_GET['var'];
JaTochNietDan
  • 1,013
  • 9
  • 13
0

Have you had a look at:

$_SERVER['REQUEST_URI']

and then split it (e.g. explode | preg_split)?

avarx
  • 509
  • 5
  • 21
0

Typically this is done using the mod_rewrite as mentioned in the other answers. But you can also get the url from the $_SERVER variable and parse the resulting string.

http://us3.php.net/manual/en/reserved.variables.server.php

Schleis
  • 41,516
  • 7
  • 68
  • 87