2

I've been messing with .htaccess for a while, and have the following rule:

RewriteRule ^(mypage|myotherpage)/?$ main.php?p=$1 [L,QSA]

If I enter http://mydomain.com/mypage/, it displays main.php as desired.

If I enter http://mydomain.com/mypage (note the lacking trailing backslash), it redirects to http://mydomain.com/mypage.html, and obviously displays a 404 Not Found error. I've tried this same URL using Chrome on the same PC, and it doesn't add the .html. I've also tried the same URL on FireFox on another PC, and again it doesn't add the .html.

Earlier when messing with .htaccess, I had rules which added .html to the URL. I've since gotten rid of these rules, but wonder if FF somehow buffered them?

Any thoughts? Thanks

  • Have you tried handling this through the DirectoryIndex? > DirectoryIndex main.php index.html – quickcel Feb 17 '14 at 15:25
  • @quickcel. No, I haven't. I deleted all browsing history from FF, and it seems to no longer do so. Maybe that is all it takes? – user1032531 Feb 17 '14 at 15:34
  • 2
    Yes, this sounds like a browser cache problem (not history). The browser should never simply add .html to a URL - that would be a serious fault of the browser. Browsers do cache external redirects (such as 301 redirects). However, the code you posted above is an internal rewrite - the browser would not cache this as it doesn't see it. – MrWhite Feb 17 '14 at 15:40
  • 1
    @w3d. I had previous used rules such as RewriteRule ^([^.]+)$ $1.html [R=301,L]. Maybe the culprit? – user1032531 Feb 17 '14 at 16:11
  • That was probably it! FWIW I've found Opera to hold on to its cache even more than Firefox - quite a problem sometimes when you're trying to test things. – MrWhite Feb 17 '14 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.