-1

I need to access a folder of my project. My project is at the root of my domain, and it is a Drupal (so the .htaccess redirects all traffic to the Drupal index.php).

I need to access my resource /other_files/ and all its content through requests

http://www.mydomain.ext/other_files/file1.php
http: //www.mydomain.ext/other_files/file2.php
etc.

I have modified the HTACESS of drupal adding this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/other_files ----> this line
RewriteRule ^ index.php [L]

But it does not work.

Other modifications that I have made in the HTACCESS

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/other_files/file1.php ----> this line
RewriteCond %{REQUEST_URI} !=/other_files/file2.php ----> this line
RewriteRule ^ index.php [L]

But it does not work.

What am I doing wrong? Thank you

  • It sounds like that folder and files exist physically, so you don't need to add any new conditions to the default rule. The !-f and !-d conditions mean Apache won't perform the rewrite if the file or folder requested physically exists – Clive Jan 11 '18 at 17:30
0

In Drupal 7 the default htaccess file is setup to allow you to access a .php file in exactly the way you want.

In D8 I think you need this:

# Allow access to PHP files in /core (like authorize.php or install.php):
  RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
# ADD THIS
  RewriteCond %{REQUEST_URI} !/other_files/[^/]*\.php$

Not the answer you're looking for? Browse other questions tagged or ask your own question.