user1614789
user1614789

Reputation: 1

simple .htaccess rewrite issues

I am new with .htaccess and need a hand with a simple rewrite.

How can I change the following:

from

mysite.com/seattle

to

mysite.com/?city=seattle

I have tried the following with now luck:

RewriteEngine On
RewriteRule ^/(.+)$ ?city=$1 [L]

Also, it would be ideal if the user still sees mysite.com/seattle.

Upvotes: 0

Views: 28

Answers (1)

Sean Bright
Sean Bright

Reputation: 120634

The following works for me:

RewriteEngine On
RewriteRule ^(.+)$ index.php?city=$1 [QSA,L]

Note that the destination filename (index.php in this case) is required, otherwise you'll get a 500 error. Also note that I added QSA so that the query string is appended properly.

Upvotes: 1

Related Questions