Ad

Create SEO Friendly URLs From _GET Query

- 1 answer

I have a search form using GET request. When I hit enter, the url is as usual not SEO friendly, is there a way in which I can make it display SEO friendly urls when entered?

Eg.

GET Request http://someurl.com?a=search&query=what+are+you+looking+for
SEO URL should be http://someurl.com/search/what+are+you+looking+for

I already created a rule

RewriteRule ^search/(\w+) index.php?a=search&query=$1

in my .htaccess that works when I manually type the SEO Url into the address bar. So I guess it's only a matter of making sure when I hit enter inside the search field, it loads the SEO Url instead of the other.

Ad

Answer

You have to redirect your orignal uri to the new uri , add the followng before your existing rule :

RewriteEngine on
RewriteCond %{THE_REQUEST} /(?:index\.php)?\?a=search&query=(.+)\sHTTP [NC]
RewriteRule ^ /search/%1? [NE,L,R]
Ad
source: stackoverflow.com
Ad