Reputation: 1
I have a Drupal-server (UBUNTU) with Drupal 8 running on it. If i place some php-file in my root-directory i can run them in my browser but when i place the same file in a sub-directory the browser gave a 403 Forbidden-error. I have already changed the permissions to 777 but it isn't working.
Can anybody help me?
"Forbidden
You don't have permission to access myfile on this server. Apache/2.4.18 (Ubuntu) Server at 192.168.51.60 Port 80"
Upvotes: 0
Views: 3177
Reputation: 11
I don't know how exactly is your server set up and in which folder is the .php file located, but Drupal installation by default contains .htaccess file which defines various rules limiting which files and folders are accessible on an apache http server. Check your .htaccess file for this section:
# For security reasons, deny access to other PHP files on public sites.
# Note: The following URI conditions are not anchored at the start (^),
# because Drupal may be located in a subdirectory. To further improve
# security, you can replace '!/' with '!^/'.
# Allow access to PHP files in /core (like authorize.php or install.php):
RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
# Allow access to test-specific PHP files:
RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
# Allow access to Statistics module's custom front controller.
# Copy and adapt this rule to directly execute PHP files in contributed or
# custom modules or to run another PHP application in the same directory.
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
# Deny access to any other PHP files that do not match the rules above.
# Specifically, disallow autoload.php from being served directly.
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
Upvotes: 1