What's the quickest method to enhance my web addresses?
I usually possess a single id ('page'). I would like the hyperlink to be www.mysite.com/page
Presuming your site operates on Apache, you should use mod_rewrite.
Simply produce a
.htaccess file in your web server with something similar to this:
RewriteEngine On RewriteBase / RewriteRule (.*) index.php?page=$1
A number of options:
- Set a custom 404 ErrorHandler to direct all pages into /dispatcher.php. Parse the $_SERVER variables to understand what to do.
- Use MultiViews to instantly turn /foo.php/extra/path/info into /foo/extra/path/info.
- Use mod_rewrite to complete whatever complex factor you would like.
mod_rewrite is easily the most complex to know in the whole, but it's (most probably) the best method of the aforementioned and may perform the most using the least quantity of PHP code needed.
I favor using .htaccess to transmit all non-static demands to index.php and parse the
$_SERVER['PATH_INFO'] variable and discover what code to operate according to that, however in your situation the simplest way might be to make use of mod_rewrite as already mentioned.