well wat im trying to do is to remove the Question mark from the url like, im using a form and the action of it is lets say city.php depending on wat u enter on the form the url will be like http://mysite/city.php?city=newyork the thing is how can i remove the question mark from the link using .htaccess

  • If you remove the city from the link, how will you know what it was? Are you planning on rewriting it to /newyork.php or something like /city.php/newyork? It might break caching but maybe you're thinking of <form method="POST" action="city.php">?
    – DerfK
    Commented Oct 26, 2010 at 11:13
  • @DerfK ummm no im not trying to use post because the link then wont be able to be bookmarked, a little more explanation: wat im trying to do is to have a dynamic .php page , how the thing works is when i click on a static image the image is send to the .php page, an the php page gets the image title and the image url and displays it on that page, and the get method builds a url with the name of the image etc in other words is like creating links on the fly... but im having dificult on removing the question mark so the link would be clean...
    – donvitto
    Commented Oct 26, 2010 at 21:21

2 Answers 2


In your .htaccess file or virtual host configuration do something like this:

RewriteEngine On
RewriteRule ^city/(.*)$ /city.php?city=$1 [P]

This will transparently proxy requests from http://mysite/city/newyork to the server as http://mysite/city.php?city=newyork.

  • i try this but doing this the city.php wont work it kinda hides it or doesn't send anything that was submitted...
    – donvitto
    Commented Oct 26, 2010 at 21:25
  • Check your log files to see what's happening. Perhaps you don't have mod_rewrite installed? Or you don't have permission to activate it from .htaccess? Or a typo? The log files will tell you how far the request is getting and what errors it encounters.
    – Caleb
    Commented Oct 27, 2010 at 7:43

I believe you are looking for URL rewriting. http://httpd.apache.org/docs/2.2/rewrite/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .