Most of the requests for my app are served from public/index.php
, but I want to serve requests to /api
from public/sites/api/api.php
. Is this possible on platform.sh?
Yes! In your .platform.app.yaml
, you’ll want to declare an additional location block for /api
, and include the directory that it should reference in the root
key and the front controller for the site in the index
key:
locations:
'/':
root: 'public'
passthru: '/index.php'
rules:
# Allow access to common static files.
'\.(jpe?g|png|gif|svgz?|css|hbs|js|map|ico|bmp|eot|woff|woff2?|tiff?|jng|wbmp|otf|ttf|pdf)$':
allow: true
'/api':
root: 'public/sites/api'
index: ['api.php']
allow: true
scripts: true