Yens
Yens

Reputation: 925

Apache mod_rewrite rewrite everything but files in .htaccess?

The following RewriteRule redirects every request to bootstrap.php except the filextenstions between the parentheses

RewriteEngine on    
RewriteRule !\.(js|ico|gif|jpg|png|css|pdf|doc|txt|htm|html|xml|ttf|flv|swf|xml|ics|htc)$ bootstrap.php

Is it possible to exclude ALL files witouth declaring them like above?

So all requests should redirect to boostrap.php if the request is not a file

Upvotes: 0

Views: 696

Answers (2)

icyfeel
icyfeel

Reputation: 91

Maybe you should check the file whether or not exists and is a regular file.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteRule ^(.*) bootstrap.php [L]

Upvotes: 3

markcial
markcial

Reputation: 9323

Maybe with that, every file with 4 letter extension would not head to bootstrap.php

RewriteEngine on    
RewriteRule !\.[\d]{4}$ bootstrap.php

Upvotes: 0

Related Questions