If you're referring to /posts/edit/522452
-style URLs as opposed to /posts.asp?action=edit&postid=522452
-style URLs (or whatever it translates to on the back end), this is typically done through a URL rewriter, such as mod_rewrite
. A rule for that URL might look like this:
RewriteRule ^/posts/(\w+)/(\d+) /posts.asp?action=\1&postid=\2
The two primary advantages to this kind of URL are that:
- "Folder"-type URLs are easier for people to type and to remember.
- The page "looks like" a page to HTTP proxies. Traditionally, proxies don't cache pages with parameters, as they don't represent separate content and change too frequently (think search results). Using "folder-style" URLs allows them to be cached normally.
In PHP, you can then access these options via $_GET['action']
and $_GET['postid']
, exactly as if the browser had asked for the rewritten form.