amb67
amb67

Reputation: 23

.htaccess redirect individual query string to specific url

Help much appreciated - i am extending my understanding of .htaccess but am having real trouble here. The situation is:

    /people.php forwards to /people

I want to forward

    /people.php?id=1 to /people/james-doe
    /people.php?id=32 to /people/lucy-brown

and so on -

but unsurprisingly what i get is:

    /people/id=1

Now I am sure there is an elegant solution to this - can anyone offer any help?

Upvotes: 2

Views: 1991

Answers (1)

anubhava
anubhava

Reputation: 786091

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)id=1(&|$) [NC]
RewriteRule ^people\.php$ /people/james-doe? [R=301,L,NC]

RewriteCond %{QUERY_STRING} (^|&)id=32(&|$) [NC]
RewriteRule ^people\.php$ /people/lucy-brown? [R=301,L,NC]

Upvotes: 1

Related Questions