0

I am seeing this url format at most websites.

site.com/extension/rar

I wonder how they get the value='rar' using $_GET.

What I know is that $_GET can be use in here

site.com/extension/index.php?ext=rar

Now I wanted to change my way of calling a variable.

I wanted to apply what most websites do.

How can I call variable in the former?

Ivo San
  • 1,233
  • 4
  • 16
  • 26

2 Answers2

0

Perhaps this works to get the "rar":

$name = basename($_SERVER['REQUEST_URI']);
fiacobelli
  • 1,960
  • 5
  • 24
  • 31
0

I most likely being done using .htaccess

It is an Apache module that allows you "rewrite" urls at the engine level based on your own set of rules. So basically it rewrites URLs on the fly.

So, in your example you could have a file named .htaccess with the following contents: (there may be other options)

RewriteEngine On
RewriteRule ^extension/([a-z0-9]+)$    somefile.php?extension=$1    [L]

Basically, you are saying: If someone is looking for a URL that looks like "extension/somenumbers-and-letters" then show the contents of "somefile.php?extension=whatever-those-number-and-leters-are".

Do a search on Apache mod_rewrite to find more information.

Ares
  • 5,905
  • 3
  • 35
  • 51