Oscar
Oscar

Reputation: 13

Apache rewrite rules for query string

Perhaps what I need to do isn't possible but I just can't find relevant information about it.

Issue: I have inherited a website with ugly and meaningless URLs and I've been asked to make them easy to remember (should have been done in the first place!), so now, I have to turn this:

http://www.domain.com/page.php?id=XXX

into this:

http://www.domain.com/name-of-page-that-refers-to-id-xxx

(e.g. www.domain.com/page.php?id=100 => www.domain.com/agenda)

Is it possible to do?

Upvotes: 1

Views: 260

Answers (1)

klaustopher
klaustopher

Reputation: 6941

You will need to make the connection from agenda to id 100 somewhere. If this doesn't change (i don't assume that's the case) you can define one rule for each site.

If it is not static than you will have to modify your application and maybe the database schema. The easiest way - in my opinion - would be to add a column sitename to your DB table in which the sites are stored and create a unique index on it. Than you have to change your application to allow URLs like page.php?sitename=agenda.

Then you can add rewrite rules that translalte www.domain.com/agenda to www.domain.com/page.php?sitename=agenda

Upvotes: 1

Related Questions