htaccess rewriterule

Hi,

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 :)
zattzAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
NopiusConnect With a Mentor Commented:
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]
0
 
Pétur Ingi EgilssonSoftware Engineer -- ConsultantCommented:
0
 
ravenplConnect With a Mentor Commented:
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]
0
 
ravenplCommented:
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]
0
 
zattzAuthor Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.