Help rewrite url htaccess or try_files


I want to know how to remove the extension from the page at the end of the url of my website. for example: > 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: {
    root * /var/www/dgx/
    encode gzip zstd
    php_fastcgi unix//run/php/php7.4-fpm.sock
    @static {
                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.