htaccess rewriterule


Could somebody write me some htaccess rewriterules that do the following:

All files ending in .jpg .gif .bmp .png .css must rewrite to /GetFile.php
and anything else must rewrite to /GetPage.php

Thanks :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pétur Ingi EgilssonSoftware Engineer -- ConsultantCommented:
I agree with PeturInqiEglisson, in _most_ cases it's better to read documentation, try it yourself  and only then ask question when something goes wrong...

But sometimes (when time is very limited and I'm onsite with a customer) even I prefer to get quick and dirty answer and only after the visit read documentation about what has been done.

So your rules are:

RewriteEngine On
RewriteBase /
RewriteRule GetFile.php - [L]
RewriteRule GetPage.php - [L]
RewriteRule (^.*\.jpg$)|(^.*\.JPG$)|(^.*\.gif$)|(^.*\.GIF$)|(^.*\.bmp$)|(^.*\.BMP$)|(^.*\.png$)|(^.*\.PNG$)|(^.*\.css$)|(^.*\.CSS$) /GetFile.php [L]
RewriteRule ^.*$ /GetPage.php [L]

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I think the idea was to pass the name to GetFile.php etc. If so

RewriteEngine On
RewriteRule GetFile.php - [L]
RewriteRule GetPage.php - [L]
RewriteRule ^(.*)\.(jpg|gif|bmp|png|css)$ /GetFile.php?file=$1 [L,NC,QSA]
RewriteRule ^(.*)$ /GetPage.php?page=$1 [L,QSA]
Need the morning coffee. The following should read
> RewriteRule ^(.*)\.(jpg|gif|bmp|png|css)$ /GetFile.php?file=$1 [L,NC,QSA]
RewriteRule ^(.*)\.(jpg|gif|bmp|png|css)$ /GetFile.php?file=$1.$2 [L,NC,QSA]
zattzAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.