The site contains redirect of all pdf files from the root of the site to the docs directory

RewriteRule ^([^/]+).pdf /docs/$1.pdf [R=301,L] 

However, in docs there is a pdf folder and any request, for example site.com/docs/pdf/qwerty.pdf , makes a redirect to site.com/docs/docs.pdf

How to make an exception to this folder?

  • Try creating a .htaccess file in the docs folder with a single line: RewriteEngine Off - Wiktor Stribiżew
  • @ WiktorStribiżew Helped, thanks. - Sergey

2 answers 2

Create a new .htaccess file in the docs folder with a single line

 RewriteEngine Off 

    Your redirection condition is incorrect: a dot can be any character if it is not escaped and the end of line anchor is not specified. Do this:

     RewriteRule ^([^/]+)\.pdf$ /docs/$1.pdf [R=301,L]