diff --git a/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf b/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf index 8284272f..58512166 100644 --- a/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf +++ b/src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf @@ -13,6 +13,11 @@ DocumentRoot ${APACHE_DOCUMENT_ROOT} DirectoryIndex index.php index.html index.htm +# Redirect /index.php/... to /... to prevent SEO duplicate content +RewriteEngine On +RewriteCond %{THE_REQUEST} \s/index\.php/ +RewriteRule ^/index\.php(/.+)$ $1 [R=301,L,QSA] + # Healthchecks: Set /healthcheck to be the healthcheck URL ProxyPass "/healthcheck" "fcgi://localhost:9000" ProxyPassReverse "/healthcheck" "fcgi://localhost:9000" diff --git a/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf b/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf index c721ece5..dd23e7e9 100644 --- a/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf +++ b/src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf @@ -18,6 +18,11 @@ DocumentRoot ${APACHE_DOCUMENT_ROOT} DirectoryIndex index.php index.html index.htm +# Redirect /index.php/... to /... to prevent SEO duplicate content +RewriteEngine On +RewriteCond %{THE_REQUEST} \s/index\.php/ +RewriteRule ^/index\.php(/.+)$ $1 [R=301,L,QSA] + # Healthchecks: Set /healthcheck to be the healthcheck URL ProxyPass "/healthcheck" "fcgi://localhost:9000" ProxyPassReverse "/healthcheck" "fcgi://localhost:9000" diff --git a/src/variations/fpm-nginx/etc/nginx/site-opts.d/http.conf.template b/src/variations/fpm-nginx/etc/nginx/site-opts.d/http.conf.template index 3b2cd4b7..02d9c54f 100644 --- a/src/variations/fpm-nginx/etc/nginx/site-opts.d/http.conf.template +++ b/src/variations/fpm-nginx/etc/nginx/site-opts.d/http.conf.template @@ -36,6 +36,11 @@ location ~* ^/storage/.*\.php$ { deny all; } +# Redirect /index.php/... to /... to prevent SEO duplicate content +location ~ ^/index\.php(/.+)$ { + return 301 $1$is_args$args; +} + # Pass "*.php" files to PHP-FPM location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; diff --git a/src/variations/fpm-nginx/etc/nginx/site-opts.d/https.conf.template b/src/variations/fpm-nginx/etc/nginx/site-opts.d/https.conf.template index a796f5d7..547bfe1b 100644 --- a/src/variations/fpm-nginx/etc/nginx/site-opts.d/https.conf.template +++ b/src/variations/fpm-nginx/etc/nginx/site-opts.d/https.conf.template @@ -42,6 +42,11 @@ location ~* ^/storage/.*\.php$ { deny all; } +# Redirect /index.php/... to /... to prevent SEO duplicate content +location ~ ^/index\.php(/.+)$ { + return 301 $1$is_args$args; +} + # Pass "*.php" files to PHP-FPM location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; diff --git a/src/variations/frankenphp/etc/frankenphp/Caddyfile b/src/variations/frankenphp/etc/frankenphp/Caddyfile index 75647941..cc883e8e 100644 --- a/src/variations/frankenphp/etc/frankenphp/Caddyfile +++ b/src/variations/frankenphp/etc/frankenphp/Caddyfile @@ -59,6 +59,10 @@ } log_skip @healthcheckpath + # Redirect /index.php/... to /... to prevent SEO duplicate content + @indexphp path_regexp indexphp ^/index\.php(/.+)$ + redir @indexphp {re.indexphp.1} 301 + php_server { {$CADDY_PHP_SERVER_OPTIONS} }