Ketan
Ketan

Reputation: 123

php - Create canonical/standardised url

I have reduced my actual problem to a simple one:

I have some php scripts that display text. E.g.

http://example.com/articles.php?id=2

could display an article with title My little cat.

However, the url is ugly for sharing. How can I implement a system whereby a user types something like http://example.com/articles/My_little_cat and be redirected to the same place?

Upvotes: 0

Views: 86

Answers (1)

Ali Idrees
Ali Idrees

Reputation: 598

You can achieve this by defining RewriteRules in the .htaccess file.

RewriteRule ^articles/My_little_cat/?$ articles.php?id=2

Upvotes: 1

Related Questions