Hi David,
Thank you for your detailed explanation and rework of the rewriting code. Unfortunately the server's configuration may be getting in the way of your suggested changes as I am getting
Code:
The web page at http://a.com/var/www/ClientFolder/404 has resulted in too many redirects.
This message is being generated with only this code:
Code:
# Strip .php file extension (ONLY if not {IS_SUBREQ}) with 301RewriteCond %{IS_SUBREQ} !true
RewriteRule ^(.*)\.php$ $1 [R=301,L]
# Note: {REQUEST_URI} has .php file extension stripped; {IS_SUBREQ} is now true
# Redirect extensionless filenames to .php version (ONLY if it exists) - hidden
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)$ $1.php [L]
# Note: {REQUEST_URI} regains .php file extension; {IS_SUBREQ} is now true
I understand your recommendation to test for a key match on loopy code, but am not sure why I get a loop when I don't using the now modified code (based on some of your recommendations).
Code:
# 404.php is a sitemap with a message that the requested page was not found.
ErrorDocument 404 /404.php
RewriteEngine on
# Redirect b.com to a.com with 301 and...
RewriteCond %{HTTP_HOST} !^b\.com$ [NC]
# Remove www (subdomain) with 301
RewriteCond %{HTTP_HOST} ^www\. [NC]
# match request URIs
RewriteRule .? http://a.com%{REQUEST_URI} [R=301,L]
# Redirect extensionless filenames to .php version (ONLY if it exists)
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)$ $1.php [L]
The one other issue I'm not sure if you were trying to show me is when someone requests a.com/somepage.php, if it exists then it is not rewritten to a.com/somepage it stays a.com/somepage.php but it does resolve if the request is made to a.com/somepage?
Many thanks and Merry Christmas
Bookmarks