.htaccess - htaccess search and replace plus sign with dash -
i have form 2 parameters city,keyword passed search.php ,after submitting redirects url website.com/search/lenovo+laptop+dealers/delhi
but need url parsed without plus signs dash in url
example: website.com/search/lenovo-laptop-dealers/delhi
code in htaccess file
rewriteengine on rewritebase / rewritecond %{the_request} \s/+search\.php\?keyword=([^&]+)&city=([^\s&]+) [nc] rewriterule ^ /search/%1/%2? [r=301,l,ne] rewriterule ^search/([\w-]+)/([\w-]+)/?$ /search.php?keyword=$1&city=$2 [l,qsa]
you can have rules this:
rewriteengine on rewritebase / rewriterule "^(search)/([^+]*)\++([^+]*\+.*)$" /$1/$2-$3 [l,nc] rewriterule "^(search)/([^+]*)\+([^+]*)$" /$1/$2-$3 [l,r=301,ne,nc] rewritecond %{the_request} \s/+search\.php\?keyword=([^&]+)&city=([^\s&]+) [nc] rewriterule ^ /search/%1/%2? [r=301,l,ne] rewriterule ^search/([\w-]+)/([\w-]+)/?$ /search.php?keyword=$1&city=$2 [l,qsa]
Comments
Post a Comment