I have this link
https://career.guru99.com/top-50-oops-interview-questions/?format=pdf
I want to redirect it to
https://career.guru99.com/pdf/top-50-oops-interview-questions.pdf
I created the following htaccess rule
RewriteEngine On
RewriteCond %{QUERY_STRING} format=pdf [NC]
RewriteRule ^top-50-oops-interview-questions /pdf/top-50-oops-interview-questions.pdf? [R=301,L]
But the challenge is I have 200+ links and I will have to manually add so many entries in the htacess which also slow down the site. Is there some regular expression that can help with this?
I want /?format=pdf
to be replaced with .pdf
2
Answers
You may try this rule:
Could you please try following, written and tested with shown samples. I am going through variable
THE_REQUEST
and getting appropriate format value from it then while rewriting placing its value.