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

user1032531
  • 1,631
  • 9
  • 26
  • 51
  • 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
  • @w3d. Yes, it does cause havoc when testing! – user1032531 Feb 17 '14 at 17:23
  • @user1032531 You might want to convert your comments into an answer ;) – DavidPostill Mar 11 '15 at 06:00

0 Answers0