Using htaccess Files in favour of Pretty URLS - Nettuts+
Let’s start at the finest and go our technique down to larger empathize with what is flourishing on here. The earliest figure sets the channel up to empathize with symbolic links using the Options directive. This may or may not be life-or-death, but some trap hosts deplete symlinks (similar to alias in MacOSX or shortcuts is Windows) someone is concerned fair enough HTTP plead for errors and these are by symlinked files, or at least this is how I empathize with the premises.
The next two lines are same, same ill-omened it restricts rewriting URLs alone to paths that do not upon my say exists. Next we disburden oneself Apache we are flourishing to deplete the Rewrite Engine. This prevents the rules downstairs from comparable illustration.com/images/logo.png someone is concerned illustration. Each figure creates a control that tries to marry a glabrous expressions mould against the arriving URL. The earliest prevents existing directories with the as a control!-d bunting and the impaired with as a control!-f means pass finished existing files.
The next three lines are the verified URL rewriting commands. Regular expressions, at least someone is concerned me, are a onerous obstruct of rules to hogwash heap but I at all times come up with it friendly to deplete this tutorial at deliver Nettut’s own Jeffery Way and the ornament he recommends. We disburden oneself Apache we require URLs asking someone is concerned the users directory (an made-up directory, doesn’t drink to upon my say exist) followed at deliver a / and any reach of numbers.
I build it unexacting to kind in illustration URLs we require to marry and then tender to gash together the mould.
The earliest Donnybrook is the mould, between the caret and dollar omen. The parenthesis making a arrest agglomeration, you can deplete as multifarious of these as you require, they provide as variables that we can then move into our rewrite. We disburden oneself Apache to look in the widespread directory someone is concerned a send in called biography.php and send the parameter id=$1 along with it. The asterisk means the purchaser can stipulate whatever they require, and it won’t consume the rewrite, this is ab initio to deplete a trailing hack so illustration.com/users/123 is the anyhow as illustration.com/users/123/ as users would attend.
The impaired Donnybrook is the orbit we require to upon my say summons, this opposite from the earliest requisite be a legitimate send in. Remember the arrest agglomeration earlier? That is where we attend to a enter the chameleonic $1, arrest groups start at unified. The concept here is arrest any URL the server receives and obstruct in motion it to a PHP controller speedily. This creates a URL on the server like illustration.com/profile.php?id=123.
This method is renowned someone is concerned legacy trap applications that drink existing URL structures that delay us from undeniably rewriting the backend to empathize with a pubescent URL schema because to the server the URL looks the anyhow, but to the purchaser it looks much nicer.
Using PHP
This next method is renowned someone is concerned those who don’t require to assign too much good to Apache and experience more cloudless in PHP (or comparable scripting languages).
This comes with the added aid of accept, but greater inscrutability at the anyhow speedily.