I need to convert htaccess to Caddyfile

Hello, I need to convert these htaccess to Caddyfile

This htaccess is at the root of the web

RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

And this in the public folder

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

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}]</IfModule>


Hi @myhumm, welcome to the Caddy community.

What have you tried so far? Do you have a Caddyfile you’re working on?

You can achieve all these with a combination of rewrite, redir, and Placeholders. The examples in the docs should be helpful to getting you started.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.