Forum Moderators: phranque
Options +MultiViews into the top of my .htaccess file. If it's that easy I don't know why everyone isn't doing it, so that's probably wrong. *But* I haven't gotten that far yet. Right now I'm stuck with a different problem. Now I've got some files that are filename.html, and some that have been changed to filename.php. What exactly do I need to put in the .htaccess file to insure:
Help will be *very* appreciated!
It's not clear if you intended any kind of precedence in case both a .html and .php file version exist, and to implement such logic would put a burden on your server, but the 'replaced' case can be covered by something like this in .htaccess:
# If html file does not exist, serve php file of same name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)\.html$ /$1.php [L]
It is occasionally required to add %{DOCUMENT_ROOT} to the filepath in the RewriteCond, depending on the server configuration. That would make it:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
Try that if the code above seems to rewrite unconditionally.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
I did spend more than an hour trying to figure this out with material here and elsewhere on the web. The procedures are so completely opaque for anyone who isn't an expert that it is rarely possible to extrapolate from the details of one example to another. For people who have to deal with these problems, say, once a year, it won't ever be realistic to expect a real understanding of the procedures to develop. Stuff like .htaccess is surely responsible for billions of dollars of lost productivity worldwide through bad design - the experts (like you) waste time having to answer similar questions over and over, and the non-experts (like me) who deal with it once or twice a year waste hours fumbling around trying to get it to work. It should have been cast onto the junk pile a generation ago along with DOS and punch cards, but then ... "the future is here, it's just not evenly distributed."