Anth23
Anth23

Reputation: 1

How to rewrite .htaccess removing and replacing

How do I rewrite this url:

www.website.com/index.php?gamename=GAME1

www.website.com/index.php?gamename=GAME2

to this:

www.website.com/GAME1

www.website.com/GAME2

It's going to be a dynamic website, fetching game names from the database via PHP. The php uses the gamename variable but I don't want that to be seen by visitors.

I'm new to all of this, so if my descriptions are different I hope you know what I mean.

Looking forward to replies, Thanks

EDIT: Some suggestions mentioned, still don't do what I'm needing done. I need to remove everything after / Except for the gamename

Upvotes: 0

Views: 40

Answers (1)

Joe
Joe

Reputation: 4897

You can use this:

RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?gamename=$1 [L]

It will work for both URLs; make sure you clear your cache before testing it.

Upvotes: 0

Related Questions