Search code examples
php.htaccess

How to make form shows only value in the URL?


I would like to build an online Malayalam to English and English to Malayalam dictionary.

There are two online dictionaries available, however it is not perfect so I have plan to build a good dictionary.

When I check some of the website both of them are used get method at the same time URL details are totally different method. Let me show how it working:

enter image description here

enter image description here

At the same time my website showing like this:

enter image description here

Is there any option to my URL like other two websites? I think both websites are using PHP with jQuery.


Solution

  • try this

    RewriteEngine On
    RewriteBase /
    
    # make pretty urls work
    RewriteRule ^dictionary/([^/]*)$ index.php?ml=$1 [L]
    
    # redirect none-pretty urls
    RewriteCond %{QUERY_STRING} ml=(.*)
    RewriteRule ^$ /dictionary/%1 [L,R=302]
    

    You'll also need some Javascript to catch the form's onsubmit, and change the url to not have the get parameters. You could do without, but that would result in an extra 302 request, and slow the pageload down a bit.

    (PS make sure you php script return a 404 page if it can't find the word in the database.)