I have these htaccess rules:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)$
RewriteRule (.*) https://%2%{REQUEST_URI} [R=301,NE,L]
# 301 externally redirect all .php extensioned requests to extensionless
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,NC,NE,L]
RewriteRule ^contact$ /?modal=contact [NC,L]
# if x.php is a file, internally add .php to x
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule !.*\.php$ %{REQUEST_URI}.php [NC,L]
Which can take any of these...
http://www.example.com/contact
http://www.example.com/contact.php
http://example.com/contact
http://example.com/contact.php
https://www.example.com/contact
https://www.example.com/contact.php
https://example.com/contact
https://example.com/contact.php
... and return: https://example.com/?modal=contact
Note that these rules also internally resolve links like https://example.com/page to https://example.com/page.php so the user will see the URL without the extension.
Although I see the desired result in the browser with a link such as https://www.example.com/contact.php, there's a 409 error. What's causing it?
NOTES:
- I see the 409 error in Google Search Console and at wheregoes.com
- I see only two 301 statuses in Chrome DevTools.
- The raw access server logs do show a 409 before the 301, but I don't understand why.
Here are the server entries from requesting https://example.com/contact.php:
IP.AD.RE.SS - - [22/Sep/2022:10:27:31 -0500] "GET /contact.php HTTP/2.0" 409 83 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" example.com IP.AD.RE.SS2
IP.AD.RE.SS - - [22/Sep/2022:10:27:31 -0500] "GET /contact.php HTTP/2.0" 301 235 "https://example.com/contact.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" example.com IP.AD.RE.SS2
IP.AD.RE.SS - - [22/Sep/2022:10:27:31 -0500] "GET /contact HTTP/2.0" 301 246 "https://example.com/contact.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" example.com IP.AD.RE.SS2
IP.AD.RE.SS - - [22/Sep/2022:10:27:31 -0500] "GET /?modal=contact HTTP/2.0" 200 5242 "https://example.com/contact.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" example.com IP.AD.RE.SS2