I'm using a standard snippet to route requests for "myfile" to "myfile.php", using Apache:
# Add .php-extension to base URLS using rewrite (so links can omit it)
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
</IfModule>
and it works. When I type "mydomain.com/myfile" in the browser, I see the page load, with no ".php" in the URL bar. Great.
But now it's also quite clear that I can still continue to still view the page at the old location "mydomain.com/myfile.php". And there are a few problems with that:
1) SEO: I'm diluting link juice, splitting the content between two URLS, one with ".php" and one without. Not crucial, but hey...
2) Any existing public links to the site out in the world will continue to see the unprettified URLs. Yech.
3) Most importantly, all my existing internal navigation links will continue to point to the unprettified URL. Dealbreaker.
My head starts to spin at this point. I think what I want is to rewrite the non-".PHP" version to the ".PHP" on the server, but also redirect the old links with the extension to the extension-less content. Is a there a standard, "best practices" way around this conundrum? Should go through my navigation and strip out all the ".php" file extensions from the links to get rid of the extensions once and for all? Seems like the wrong path, but it's occurred as a possibility :) Even more severely, would it be safe to have PHP files saved without extensions in a LAMP stack? (I've never even tried, too conditioned to avoid it). How do I make the transition to pretty URLS complete?
Thanks in advance for any guidance.