redirection and mapping for same page using htaccess not working
Ex . www.xyz.com?view=aa¶m=bb
-- redirect it to www.xyz.com/aa/bb
Then map www.xyz.com/aa/bb
to
www.xyz.com?view=aa¶m=bb
below is the rules.
redirection
RewriteCond %{QUERY_STRING} ^view=([^&]*)&p=([0-9]+)&/(.*)$
RewriteRule ^insights/(.+?)\.html$ insights/$1/%1/%2-%3.html? [R=301,L]
mapping
RewriteRule ^insights/(.*)/(.*)/([0-9]+)-(.*)\.html$ /insights/$1.html?view=$2&p=$3&/$4 [L,QSA,NC]
Keep these 2 rules at top of your .htaccess:
This should work to what you're trying to do:
Change
R=302
toR=301
only after you have confirmed the rule is working to avoid your browser from caching wrong redirects.