views:

32

answers:

2

i am writing a site from scratch using php/mysql and am using GET requests to pass data between the pages.

at the moment my links look like:

http://pkh:55/?service=213971&type=FSD

but i would like to use mod_rewrite to make them more relevant, ie:

http://pkh:55/FSD/services/football-youth-club/

i've had a look through the wordpress code but i'm none the wiser.

please help!

thanks :)

A: 

Please check this website. This is one of the greatest sites I've ever discovered. Please read thoroughly & do some testing simultaneously, so that you can get a grip of what's going around & how to get what you want.

Also make sure that the hosting server has provided permission to use HTAccess & MOD_REWRITE, because some servers don't provide this permission by default. If this is case, then you need to send a request to the server administrator right away, asking him to provide permission to use MOD_REWRITE & HTAccess.

Hope it helps.

Knowledge Craving
+1  A: 

Assuming that your site is currently working by outputting and accepting the first type of link. The basic process is this...

  • ensure you have a method in your application for associating 'football-youth-club' to the same set of information you retrieve with '213971'. Generally this means adding a permalink field to the database table.

  • update processing of your $_GET information to use the permalink field in your database rather than the id. So that your links will look like...

    http://pkh:55/?service=football-youth-club&type=FSD

  • update outputting of all links on your site so that it outputs the second format.

  • create the mod_rewrite rules to map this pretty format to the functionality you have implemented...

    RewriteEngine On RewriteCond %{REQUEST_URI} !-f RewriteCond %{REQUEST_URI} !-d RewriteRule ^([a-z-A-Z0-9-]+)/services/([a-z-A-Z0-9-]+)/? /?service=$2&type=$1

Cags