Marco Aurélio Deleu
Marco Aurélio Deleu

Reputation: 4367

Rewrite Mode and PHP using .htaccess not working (Error 404)

Here is my .htaccess:

RewriteEngine on
RewriteRule !\.(js|ico|gif|ini|jpg|png|css|html|swf|flv|xml)$ index.php

I've been using this file for about a year now and frankly, if you ask me I'd say it means: If you're trying to access something NOT ended with js, ico, gif... flv, xml THEN redirect to index.php

Now I'm trying to deploy an application at a new server (centOS WITH mod_rewrite enabled) and I get the Error 404 when trying to access stuffs that usually works (at a different web server, for instance).

Since I know too little about it, I'd like some input on what should I be looking for to find the problem. Thanks in advance.

Upvotes: 0

Views: 84

Answers (1)

poncha
poncha

Reputation: 7866

You should perform that kind of match in RewriteCond

RewriteEngine on

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_URI} !\.(js|ico|gif|ini|jpg|png|css|html|swf|flv|xml)$
RewriteRule .* index.php

Note: the first rule is needed so that the rules won't loop (exclude index.php itself from rewriting).

Upvotes: 1

Related Questions