.htaccess rewrite rule from one page to another not working -


i have problem .htaccess 1 page in website.

i need rewrite page

https://www.lepremier.cz/product/index?categoryid=61 

to

https://www.lepremier.cz/33-loake 

i tried 2 rules

rewriterule ^/product/index?categoryid=61$ http://www.lepremier.cz/23-boty-loake [r=301,l]  redirectmatch 301 /product/index?categoryid=61(.*) /33-loake/$1 

but not working.

thanks help.

the request parameters (the stuff following ? in uri not part of request url. means cannot match in rewriterule. have use rewritecond instead:

rewriteengine on rewritecond %{query_string} "categoryid=61" rewriterule ^/product/index$ http://www.lepremier.cz/23-boty-loake [r=301,l] 

this documented, makes sense if start reading documentation of tools want use: http://httpd.apache.org/docs/current/mod/mod_rewrite.html


and general note, since stumble on this:

the pattern chose not work in .htaccess style files, since starts leading slash (/) never match. matching in .htaccess style files works on relative paths obvious reasons.

nevertheless did not modify that, since should prefer place such rules inside http servers host configuration anyway. in there chosen syntax leading slash will work expected. .htaccess style files notorioously error prone, hard debug , really slow http server down nothing. offered last option situations people not have access host configuration. example when using cheap shared hosting provider.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -