Reputation: 3
I need help in 301 permanent URL redirection of dynamic URL's
https://www.xyz.co/certificate.php?certify=iso-haccp
should redirect to
https://www.xyz.co/certificate/iso-haccp-certification
I want to do it using .htaccess file because there are so many url's like this, help me guys?
Upvotes: 0
Views: 77
Reputation: 7073
Try this code :
RewriteEngine On
RewriteCond %{QUERY_STRING} ^certify=(.*)$
RewriteRule ^certificate\.php$ /certificate/%1-certification? [R=301]
Upvotes: 1
Reputation: 7880
A literal redirection would look like this:
RewriteBase /
RewriteCond %{QUERY_STRING} certify=(iso-haccp)
RewriteRule (certificate)\.php /$1/%1-certification? [R=301,L]
We're not using ^
or $
in this example around the query string because it can allow for other variables that could be passed. I'm adding a ?
to the end of the redirection string to stop the default behavior of query string append.
Upvotes: 1