MoHo
MoHo

Reputation: 2583

Rewrite url only for a specific id

I have this URLcontent.php?type=4 and value for type is changing all the time. What should I write in htaccess file in order to have this URL: content/flower

The important part is I only need it for type=4, so if the type=5 or type=6, I don't bother.

As result by typing content/flower in url, apache should look for content.php?type=4.

Upvotes: 0

Views: 90

Answers (2)

Raphael Guimarães
Raphael Guimarães

Reputation: 124

RewriteRule ^content/flower$ /content.php?type=4 [NC]

Edit: I agree with the first solution

Upvotes: 0

Egg
Egg

Reputation: 1769

You can use RewriteRule to redirect to the new URL.

RewriteRule ^content/flower$ /content.php?type=4 [NC]

Therefore, the URL content/flower redirects the request to content.php?type=4 without the client knowing.

You can then edit this .htaccess file to type=5 or type=6 with the same public URL being shared and used.

EDIT: Your question was unclear as to what redirects to what, so I've update this answer to reflect the last line if your question.

Upvotes: 3

Related Questions