Help with converting a .htaccess file to caddy-language

1. The problem I’m having:

I need to rewrite the information in a .htaccess file to Caddy-ese and I have zero experience with .htaccess logic.
I have tried to educate myself but what I’m seeing doesn’t make sense.
Can anyone help translate?
I am using Caddy v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
Here is the htaccess file.

# ~~start~~ Do not remove this comment, thirty bees will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automatically generated by thirty bees e-commerce open-source solution
# http://www.thirtybees.com - http://www.thirtybees.com/forums

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>

RewriteEngine on


# Domain: store.eiphax.tech
RewriteRule . - [E=REWRITEBASE:/]

# Webservice API
RewriteRule ^api$ api/ [L]
RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]


# AlphaImageLoader for IE and fancybox
RewriteCond %{HTTP_HOST} ^store.eiphax.tech$
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
</IfModule>

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/woff .woff
AddType font/woff2 .woff2
<IfModule mod_headers.c>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg)$">
		Header set Access-Control-Allow-Origin "*"
	</FilesMatch>
</IfModule>

#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

# ~~end~~ Do not remove this comment, thirty bees will keep automatically the code outside this comment when .htaccess will be generated again

The only relevant parts are these:

I think this is just a simple rewrite /api /api/ i.e. add a / to the end if exactly /api was requested. You might not need this at all, but it’s cheap.

@api-rewrite path_regexp api ^/api/(.*)
rewrite @api-rewrite /webservice/dispatcher.php?url={re.api.1}
@img-rewrite path_regexp img ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$
rewrite @img-rewrite /js/jquery/plugins/fancybox/images/{re.img.1}.{re.img.2}

hi francis.
thanks for jumping in to help again.
i have added these lines, but something doesn’t seem to be working.
if you go to https://store.eiphax.tech, add anything to cart then try to proceed through the checkout, it complains about ‘too many redirects’. not sure if this is a caddy thing or an application thing. i cant find much useful by inspecting the request. do you have any ideas?

Please enable the debug global option, make some requests and show Caddy’s logs. Make requests with curl -v to show what it’s doing.

I can’t really help you debug your application. That’s on you. All I do is help you configure Caddy such that it works. So you need to figure out what’s going wrong and once you understand that we can find a fix.

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