For this tutorial a host with PHP Support (and .htaccess) is reccomended.
For this example I am going to show you how I changed my episode guide script urls to be tidier. First things first, Open up notepad (or a text editor) and add this, RewriteEngine On That is turning Apache's mod_rewrite on. Now for the entry, My episode guide uses urls like, ?module=episode&id=101 So to change that into, /episode/101/ We use regexp. RewriteRule ^(.*)/(.*) /episodeguide.php?module=$1&id=$2
^(.*)/(.*)
is the new address we want, If we replace the regexp with some pretend content like episode/101 then you can see how it works.
/episodeguide.php?module=$1&id=$2
That replaces the content of (episode/101) and puts each in its correct place, So now when people visit http://yourdomain.com/episode/101/ they are really seeing http://yourdomain.com/episodeguide.php?module=episode&id=101
RewriteRule ^(.*)/(.*) /episodeguide.php?module=$1&id=$2
The / is important, This seperates what you want to use, with what you want to show.
If I wanted to have more query strings, I would just replace with:
RewriteRule ^(.*)/(.*)/(.*)/(.*) /blah.php?input=$1&extra=$2&but=$3&while=$4
You get the idea :) You now should have the knowledge to make friendly urls using mod_rewrite
Comments
Post new comment