Help rewrite url htaccess or try_files

Hello,

I want to know how to remove the extension from the page at the end of the url of my website. for example: https://example.com/inscription.php > how to remove “.php” in my URL? i am using caddy v2.6.2 for debian 11 bullseye.

here is an example of my config from my caddyfile:

exemple.com:443 {
    root * /var/www/dgx/exemple.com
    encode gzip zstd
    file_server
    php_fastcgi unix//run/php/php7.4-fpm.sock
    @static {
                file
                path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.pdf *.webp
        }
    header @static Cache-Control max-age=5184000
}

Thanks for help !

You can do this:

php_fastcgi unix//run/php/php7.4-fpm.sock {
	try_files {path} {path}.php {path}/index.php index.php
}

See the docs in php_fastcgi (Caddyfile directive) — Caddy Documentation to understand how this works, it’s well explained.

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