apache - Redirect rule not fired in htaccess -
any thoughts why url example.com/hotelinfo.aspx?idhotel=2
not redirecting 1 example.com/new-url
using following rule in .htaccess
?
redirect 301 /hotelinfo.aspx?idhotel=2 http://www.example.com/new-url
you cannot match query string using redirect
directive, use mod_rewrite
rules instead.
you can use code in document_root/.htaccess
file:
rewriteengine on rewritecond %{query_string} ^idhotel=2$ rewriterule ^hotelinfo\.aspx$ http://www.example.com/new-url? [l,r=302,nc]
once verify working fine, replace r=302
r=301
. avoid using r=301
(permanent redirect) while testing mod_rewrite rules.
Comments
Post a Comment