Trying to get Statamic to run in Caddy and am tripping up on converting the rewrite rules. Laravel Valet is able to run Statamic (with Caddy on the backend) through its “drivers” but I’m beaten.
Statamic htaccess file
`# Turn on the Rewrite Engine`
`RewriteEngine On`
`# ------------------------------------------------------------------------------`
`# Dynamic RewriteBase`
`# ------------------------------------------------------------------------------`
`# For most servers, this will be able to dynamically find your site's root,`
`# but if it doesn't for you, comment out these next two lines...`
`RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$`
`RewriteRule ^(.*)$ - [E=BASE:%1]`
``
`# ...and uncomment out the following line, then set as you need to`
`#RewriteBase /`
``
`# ------------------------------------------------------------------------------`
`# Protect System Files`
`# ------------------------------------------------------------------------------`
`RewriteRule ^_app - [F,L]`
`RewriteRule ^_config - [F,L]`
`RewriteRule ^_cache - [F,L]`
`RewriteRule ^_content - [F,L]`
`RewriteRule ^_logs - [F,L]`
`RewriteRule ^_storage - [F,L]`
`RewriteRule ^admin/themes/[^/]*/(?:layouts|templates) - [F,L]`
`RewriteRule ^.*?\.yml$ - [F,L]`
`RewriteRule ^.*?\.yaml$ - [F,L]`
`RewriteRule ^.*/?\.git+ - [F,L]`
``
`# This will prevent all .html files from being accessed.`
`# You may want to remove this line if you want to serve`
`# static files outside of Statamic`
`# RewriteRule ^(.*)?\.html$ - [F,L]`
``
``
`# ------------------------------------------------------------------------------`
`# Remove Trailing Slashes from URL`
`# ------------------------------------------------------------------------------`
`RewriteCond %{REQUEST_FILENAME} !-d`
`RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]`
``
``
`# ------------------------------------------------------------------------------`
`# Remove the Index File`
`# ------------------------------------------------------------------------------`
`RewriteCond %{REQUEST_FILENAME} !-f`
`RewriteCond %{REQUEST_FILENAME} !-d`
`RewriteRule ^(.*)$ index.php [QSA,L]`
I think I have the protected system files figured out - pretty simple, especially since there is an example.
RewriteRule ^_app - [F,L]
becomes
`rewrite {`
` regexp ^/_app`
` status 403`
`}`
Its the last ones holding me up - removing trailing slash and the index.php. I’ve scoured the forums and google and attempted to use the wordpress and other examples I’ve found as a base but just not getting there.