php - How to redirect old links to new SEO friendly links? -


i started developing web sites. know question has been asked many times. although, checked of them, not manage redirect old links new seo friendly links. mysite.com/search.php?word=thanks , mysite.com/thanks boths works. when form submtited, site runs old link. have been trying solve problem , searching web hours. have added code @ bottom of .htdocs file didn't work.

rewriterule search.php?word=^(.*)$ $1 [r=301,l] 

here .htdocs codes

rewriteengine on rewritecond %{http_user_agent} ^webwhacker [or] rewritecond %{http_user_agent} ^webzip [or] rewritecond %{http_user_agent} ^wget [or] rewritecond %{http_user_agent} ^widow [or] rewritecond %{http_user_agent} ^wwwoffle [or] rewritecond %{http_user_agent} ^xaldon\ webspider [or] rewritecond %{http_user_agent} ^zeus rewriterule .* - [f] rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ search.php?word=$1 [qsa,l] 

thanks

you can use new redirect rule:

rewriteengine on  rewritecond %{http_user_agent} ^webwhacker [or] rewritecond %{http_user_agent} ^webzip [or] rewritecond %{http_user_agent} ^wget [or] rewritecond %{http_user_agent} ^widow [or] rewritecond %{http_user_agent} ^wwwoffle [or] rewritecond %{http_user_agent} ^xaldon\ webspider [or] rewritecond %{http_user_agent} ^zeus rewriterule .* - [f]  rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  rewritecond %{the_request} /search\.php\?word=([^\s&]+) [nc] rewriterule ^ /%1? [r=301,l]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ search.php?word=$1 [qsa,l] 

Comments