Search code examples
apache.htaccesscaddy

htaccess to Caddy rewrite


I'm trying to install Cachet on a Caddy server however when I try to access the webpage it tries to go to /setup, but Caddy gives me '404 Not Found'.

For Apache they say you have to use this:

<Directory "/var/www/Cachet/public">
    Require all granted 
    # Used by Apache 2.4
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

But how would I do this in my Caddyfile? I guess it has something to do with the symbolic links as there is no actual setup folder.

.htacces of Cachet

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


Solution

  • But how would I do this in my Caddyfile? I guess it has something to do with the symbolic links as there is no actual setup folder.

    In fact it is not about symbolic links, but URL Rewriting.
    Cachet is a Web application developed using Laravel 5, and every HTTP request is routed to public/index.php.

    So the way to achieve you installation is:

    • Enabling .htaccess.
    • Enabling mod_rewrite on Apache

    So all the HTTP requests will be routed to public/index.php and it will call the App/Http/Controllers/SetupController. It's not about a symbolic link.

    I do not know Caddy so I can't explain you how to configure it, but there is a Caddy post where someone needs to enable mod_rewrite in Caddy.