my .htaccess in the root folder includes the following lines :

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^(.*)\.htm$ http://example.com/?city=$1 [NC]

when I open the address http://example.com/bla.htm, my browser doesn't hide the GET values specified in the .htaccess, it redirects me to ?city=bla. eventhough I'm not using the [R] switch. This has always worked for me before (as I remember, haven't dealt with htaccess in a while). What's wrong here ?

Comments

He wants it to silently return the contents of example.com/?city=$1 without changing the URI in the address bar.

Written by Simon Brown

Accepted Answer

When you redirect to an entire URL, it doesn't do URL rewriting (you can't exactly rewrite URLs on someone else's website).

Assuming both URLs are on the same server, you need to do something like

RewriteRule ^(.*)\.htm$ index.php?city=$1 [NC]

Also, I'd recommend getting into the habit of using the [L] switch whenever you can - it helps avoid bugs when you have a lot of URLs to rewrite.

Written by Zarel
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki