Asesha George Asesha George -4 years ago 93
PHP Question

how to rewrite SEO-friendly url markep in htaccess

i am trying to convert my URL in to SEO Friendly url. i don't have much knowledge in htaccess rewrite rules bellow is my URL.

https://www.zesteve.com/search.php?loc=Guntur&q=manjunath-cake-shop


the URL should be

https://www.zesteve.com/Guntur/manjunath-cake-shop


i tried bellow one

RewriteEngine On
RewriteCond $1 ^search
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ search.php?q=$1 [L,QSA]


i got the result as

https://www.zesteve.com/search?loc=Guntur&q=manjunath-cake-shop


Edit

i am using jquery to redirect

window.location.href = 'search?loc=' + location[0] + '&q='+ search_term;

Answer Source
RewriteRule ^([^/]*)/([^/]*)$ /search.php?loc=$1&q=$2 [L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download