W
W
WebLedNik2020-08-30 14:08:14
htaccess
WebLedNik, 2020-08-30 14:08:14

How to configure .htaccess so that the rule is not executed for a specific directory on the server?

Hello.

There is a code that removes the .php extension from the URL:

RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^.*$ $0.php [L,QSA]
  RewriteCond %{THE_REQUEST} ([^\s]*)\.php(\?[^\s]*)?
  RewriteRule (.*) %1 [R=301,L]


I need to create a condition that would prohibit this code from being applied to a specific directory and its contents on the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-08-30
@WebLedNik

RewriteCond %{REQUEST_URI} !^/folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L,QSA]

RewriteCond %{REQUEST_URI} !^/folder/
RewriteCond %{THE_REQUEST} (\S+)\.php
RewriteRule ^ %1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question