skip to Main Content

Replace query string with file extension using htaccess Rule – Apache

I have this link https://career.guru99.com/top-50-c-sharp-interview-questions-answers/?format=pdf I want to redirect it to https://www.guru99.com/pdf/c-sharp-interview-questions.pdf I created the following htaccess rule RewriteCond %{QUERY_STRING} format=pdf [NC] RewriteRule ^c-sharp-interview-questions.html /pdf/c-sharp-interview-questions.pdf? [R=301,L] But the challenge is I have 100+ links and I will have to manually…

VIEW QUESTION

Forward one path to another AND convert spaces to hyphens along the way – Apache

Trying to change https://www.example.com/search/label/my%20search%20term to https://www.example.com/tag/my-search-term Per the answer from @anubhava below, Option 2 works: RewriteEngine On RewriteRule ^search/label/(S+)[-s]+(S+)$ /tag/$1-$2 [NE,NC,L,R=301] RewriteRule ^search/label/(S+)$ /tag/$1 [NE,NC,L,R=301] RewriteRule ^(search/label/S+)s+(S+s.*)$ /$1-$2 [NC,L] Thanks!

VIEW QUESTION
Back To Top
Search