0

Per the recommendation in this thread, I am trying to rewrite my .htaccess file to remove the .html suffix from my site's urls. For example, I want "my-website.ca/ecology.html" to be shortened to "my-website.ca/ecology". However, I am getting some errors (see below).

I appended the following code to my .htaccess file. (Note: I already had RewriteEngine On from previous tinkering.)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

The results have been... weird. Sometimes it doesn't work, and I'm given a "bad flag delimiter" error. Other times, it works for all but one webpage: ecology.html. When I try to access that, I get a weird page asking me to contact the site's webmaster and the log has a "no matching directoryindex"

I worked out that "ecology.html" had a common name with a folder called "ecology" which I have since renamed to "science". But that didn't fix it.

I'd appreciate any advice.

PhiliDips
  • 1
  • 1
  • Folders and files getting confused points towards content negotiation. Turn it off. – arkascha Dec 17 '22 at 21:43
  • And make sure that you test using a fresh anonymous browser window. So that you are not looking at client side cached responses. – arkascha Dec 17 '22 at 21:44

0 Answers0