Forum Moderators: open

Message Too Old, No Replies

controling the URL using a form

form url post

         

sporb

6:20 pm on May 25, 2007 (gmt 0)

10+ Year Member



i want to my url to change to www.domain.com/search/keywords when someone clicks on search. right now i have a form that takes the user to www.domain.com/search.php?words=keywords. i haven't been able to find anything about how to do this. any help is much appreciated. thanks.

rocknbil

7:32 pm on May 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard sporb! I hope you are hosted on a Linux server, because if you are, mod_rewrite is your new best friend. It is an apache module that rewrites URL's to simplify links. If it is installed on your server, you put this in an .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ /search.php [L]

This says if the request is not a file (-f), and it is not a directory (-d), direct it to search.php. In search.php, you will have to add some programming that takes the referrer string and correctly converts /search/keywords to query words=keywords.

(Edit: this board software removed some spaces, there needs to be a space before the exclamation --->!)