1

I'm experiencing some issues with mod_rewrite in htaccess.

Let's for instance say I request example.com/foo/, it works perfectly if I don't have a file starting with "foo.*" in the root directory.

Let's say I have news.php, sitemape.xml, style.css in root, I can't use /news/ or /sitemap/ or /style/ , it will give a 404 like /news.php/ etc.

Here's my rewrite string. It works locally with my Apache 2.2.22 but not at my web-host with the same Apache version.

RewriteRule ^([A-Za-z0-9]+)/?$ index.php?category=$1 [NC,L]

Anyone has a clue?

Julius Vainora
  • 47,421
  • 9
  • 90
  • 102

1 Answers1

4

This sounds like Multiviews rearing its ugly head when its not wanted. It may be that your host automatically turns on the Multiviews option by default, and mod_negotiation then tries to "guess" what the request is for, and if it's close enough (like with /news/ and /news.php), it will automatically serve it, and disregard whatever mod_rewrite rules you may have.

Try turning off multiviews. You can do this in your htaccess file using the Options directive (assuming your host has allowed Options):

Options -Multiviews
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Adding the row above gave "Internal Server Error" so I guess that I'm not allowed to do that. – user1677709 Jun 29 '13 at 19:41
  • @user1677709 then you need to ask your host to make sure it's turned off or add an `AllowOverride Options` for you – Jon Lin Jun 30 '13 at 16:55