1st Solution: Try following in case you are hitting http://localhost:80/top-50-c-sharp-interview-questions-answers/?format=pdf
in your browser. Change [NC,L]
TO [R=301,NC,L]
in case you want to redirect your URL in browser.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^career.guru99.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{QUERY_STRING} ^format=(.*) [NC]
RewriteRule ^top-50-(.*)/?$ pdf/c-sharp-$1.%1 [NC,L]
2nd solution: Could you please try following, written based on your shown samples(considering that you want to hit http://localhost:80/pdf/c-sharp-interview-questions.pdf
in your browser).
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^career.guru99.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteRule ^(pdf)/([^.]*).(pdf)/?$ top-50-$1/?format=$2 [NC,L]
NOTE: Either use 1st OR use 2nd solution at a time please. Please make sure you clear your browser cache before testing your URLs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…