Skip to content

Commit 8203769

Browse files
authored
Add redirect rules to prevent SEO duplicate content across web server configurations (#646)
1 parent e49228a commit 8203769

5 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/variations/fpm-apache/etc/apache2/vhost-templates/http.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ DocumentRoot ${APACHE_DOCUMENT_ROOT}
1313
DirectoryIndex index.php index.html index.htm
1414
</Directory>
1515

16+
# Redirect /index.php/... to /... to prevent SEO duplicate content
17+
RewriteEngine On
18+
RewriteCond %{THE_REQUEST} \s/index\.php/
19+
RewriteRule ^/index\.php(/.+)$ $1 [R=301,L,QSA]
20+
1621
# Healthchecks: Set /healthcheck to be the healthcheck URL
1722
ProxyPass "/healthcheck" "fcgi://localhost:9000"
1823
ProxyPassReverse "/healthcheck" "fcgi://localhost:9000"

src/variations/fpm-apache/etc/apache2/vhost-templates/https.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ DocumentRoot ${APACHE_DOCUMENT_ROOT}
1818
DirectoryIndex index.php index.html index.htm
1919
</Directory>
2020

21+
# Redirect /index.php/... to /... to prevent SEO duplicate content
22+
RewriteEngine On
23+
RewriteCond %{THE_REQUEST} \s/index\.php/
24+
RewriteRule ^/index\.php(/.+)$ $1 [R=301,L,QSA]
25+
2126
# Healthchecks: Set /healthcheck to be the healthcheck URL
2227
ProxyPass "/healthcheck" "fcgi://localhost:9000"
2328
ProxyPassReverse "/healthcheck" "fcgi://localhost:9000"

src/variations/fpm-nginx/etc/nginx/site-opts.d/http.conf.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ location ~* ^/storage/.*\.php$ {
3636
deny all;
3737
}
3838

39+
# Redirect /index.php/... to /... to prevent SEO duplicate content
40+
location ~ ^/index\.php(/.+)$ {
41+
return 301 $1$is_args$args;
42+
}
43+
3944
# Pass "*.php" files to PHP-FPM
4045
location ~ \.php$ {
4146
fastcgi_pass 127.0.0.1:9000;

src/variations/fpm-nginx/etc/nginx/site-opts.d/https.conf.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ location ~* ^/storage/.*\.php$ {
4242
deny all;
4343
}
4444

45+
# Redirect /index.php/... to /... to prevent SEO duplicate content
46+
location ~ ^/index\.php(/.+)$ {
47+
return 301 $1$is_args$args;
48+
}
49+
4550
# Pass "*.php" files to PHP-FPM
4651
location ~ \.php$ {
4752
fastcgi_pass 127.0.0.1:9000;

src/variations/frankenphp/etc/frankenphp/Caddyfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
}
6060
log_skip @healthcheckpath
6161

62+
# Redirect /index.php/... to /... to prevent SEO duplicate content
63+
@indexphp path_regexp indexphp ^/index\.php(/.+)$
64+
redir @indexphp {re.indexphp.1} 301
65+
6266
php_server {
6367
{$CADDY_PHP_SERVER_OPTIONS}
6468
}

0 commit comments

Comments
 (0)