<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Rewrites urls in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
In my current config, I have problem that when I go on http://example.com/subpage1/subsubpage1 , it does not change page content to that page, content is always at root url frontpage.
rewrite {
r ^(.+)$
to {path} {path}/ /index.php?page={1}
}
I believe that without the capture group (the r subdirective), the placeholder {1} would have no data, so you’d be rewriting to /index.php?page= every time.
Incidentally, you can use the php preset to cut down your Caddyfile a little (see the fastcgi docs). Your fastcgi block would become a one liner: