I know that it is trying to load the .html version, i am pretty sure at least. I also think that it is something in an .htaccess file. I have tried a few different things from searching google and come up short. Basically i want it to work so that if there is no .html file by the name entered, it will go to the php one.
Is this possible?
In htaccess
RewriteEngine on
RewriteRule ^eat$ eat.php [L]
Use MultiViews
Add this to apache configuration (either in httpd.conf
, VirtualHost
config, or in .htaccess
):
Options +MultiViews
Using rewriting for this is an overkill, when content-negotiation
can do the job.
Try this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -s
RewriteRule ^.*$ %{REQUEST_URI}.php [L,QSA]
The above rules say, if the requested file is of 0 size, or does not exist as a file, symbolic link, or directory and a file of the same name with a .php
extension exists, then rewrite to the .php
file.
This effectively rewrites site.com/foo
to site.com/foo.php
where foo
can be anything.
I'm not quite clear on what you want. If you want to map non-existant .html
files to a .php
extension, try this instead:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ $1.php [L,QSA]
This just says if the requested file does not exist and ends in .html
, then grab the file name (less the .html
) and try to rewrite to the .php
extension.