Could someone help me convert this .htaccess file to Caddy rewrite?

# Pretty Permalinks
RewriteRule ^(images)($|/) - [L]
RewriteCond %{REQUEST_URI} !^action=logout [NC]
RewriteCond %{REQUEST_URI} !^action=login [NC]
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?filename=$1 [NC,QSA,L]

I’m not the best with porting it over. Any help is greatly appreciated!

Something like

example.com {
    rewrite {
        r ^(images)($|/)
        to {2}
    }
    rewrite {
        rewrite {
            r ^(.*)$
            if {path} not_has index.php
            to index.php?filename={1}
        }
    }
}

Pretty sure Go doesn’t follow symlinks at all though :confused: So that part will break.

Also the second one is a start but I’m not sure quite how to convert the request_filename bit.

See docs for rewrite

I get
2016/07/07 12:40:33 Caddyfile.domain.com:22 - Parse error: Wrong argument count or unexpected line ending after 'rewrite'

Line 22 is the one with the ***'s

...
rewrite {
        r ^(images)($|/)
        to {2}
    }
    rewrite {
        **rewrite {**
            r ^(.*)$
            if {path} not_has index.php
            to index.php?filename={1}
        }
    }
}

The nested rewrite looks like an accident.

 rewrite {
       r ^(.*)$
       if {path} not_has index.php
       to index.php?filename={1}
}
1 Like

Hi, can I get help also? I’m using firebase now for hosting, like this:
{
“source”: “**”,
“destination”: “/index.html”
}

What it means is if you don’t find it, go to index.html or /.
But if there is html, or img or css or js or such than load it.

cheers.

@cekvenich Hi vic, I’m sure someone will help you in your other thread if they know the answer. :slight_smile: Let’s keep this thread on-topic.

It’s alright guys. I gave up on figuring it out. :wink:

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