user1263260
user1263260

Reputation: 243

hidequery string parameters from the url using url rewriting

In my php web site, I need to display my urn in a specific manner

I need to hide the query string parameters and just want to display the value in the URL i.e.

mydomain.com/city.php?place='usa'&id=2

I need to display

my domain.com/city-2/usa

Is it possible?

Please help me. I am in a serious situation.

Thanks in advance

Upvotes: 0

Views: 72

Answers (1)

zerkms
zerkms

Reputation: 254886

Yes, it is possible:

RewriteEngine On
RewriteBase /

RewriteRule ^city-(\d+)/(.*) city.php?place=$2&id=$1

You need to put it into the .htaccess placed in the web root of your site. To get it worked you need to have .htaccess parsing enabled and mod_rewrite apache module (assuming you have apache as a web server) enabled as well.

More in official documentation

Upvotes: 1

Related Questions