Concrete5 CMS redirect rules

Hi,
is it possible to convert these rules to caddy? I tried for some time, but now Concrete5 is in redirect loop.

>>> For Apache <<<
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME}/index.html !-f
	RewriteCond %{REQUEST_FILENAME}/index.php !-f
	RewriteRule . index.php [L]
</IfModule>

>>> For nginx <<<
location / {
	set $do_rewrite 1;
	if (-f $request_filename) {
		set $do_rewrite 0;
	}
	if (-f $request_filename/index.html) {
		set $do_rewrite 0;
	}
	if (-f $request_filename/index.php) {
		set $do_rewrite 0;
	}
	if ($do_rewrite = "1") {
		rewrite ^/(.*)$ /index.php/$1 last;
	}
}

It’s not a redirect, it’s an internal rewrite. Should be simple enough. It’s effectively trying, in succession:

  1. {path}
  2. {path}/index.html
  3. {path}/index.php
  4. /index.php

So try a rewrite like so:

rewrite {
    to {path} {path}/index.html {path}/index.php /index.php
}

Thanks, this worked for me:

    rewrite {
            to {path} {path}/index.html {path}/index.php /index.php/{uri_escaped}
    }

I’ll make pull request to caddyserver examples.

Ok now I have added pull request:

1 Like