LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache rewrite rule for jpg and png files . (http://www.linuxquestions.org/questions/linux-server-73/apache-rewrite-rule-for-jpg-and-png-files-4175454955/)

call_krushna 03-21-2013 03:14 AM

Apache rewrite rule for jpg and png files .
 
Hi Team,

We have 2 requirement for rewrite rule in apache as follows

1)will check for url for certain file extn *.jpg,*.png in Apache should identify the URL like as www.prestaging.goodworks.com/images/image.jpg

2) Apache should rewrite www.prestaging.goodworks/images/image.jpg to ->
static.int.goodworks.com/images/image.jpg


All jpgs will present in static.int.goodworks.com/images/

I have tried several rewrite ruls .Nothing is working .
I have tried to add following blocks in my apache config

RewriteRule ^(.*)$ / [R=302,NC,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} ^/.*\.(gif|jpg|png)$ [NC]
RewriteRule (.*\.(jpg|gif|png))$ http://static.int.goodworks.com$1 [R=300,NC,L]

When I am trying

www.prestaging.goodworks.com/test.jpg in browser , it is not working

any help is highly appreciable .

bathory 03-21-2013 04:56 AM

Hi,

Unless I miss something, you may try this:
Code:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/.*\.(gif|jpg|png)$ [NC]
RewriteRule (.*\.(jpg|gif|png))$  http://static.int.goodworks.com$1 [R=302,NC,L]

N.B. Check whether you need R=302 (temporary) or R=301 (permanent) in the rewrite rule, but not R=300

Regards

call_krushna 03-21-2013 04:58 AM

Quote:

Originally Posted by bathory (Post 4915804)
Hi,

Unless I miss something, you may try this:
Code:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/.*\.(gif|jpg|png)$ [NC]
RewriteRule (.*\.(jpg|gif|png))$  http://static.int.goodworks.com$1 [R=302,NC,L]

N.B. Check whether you need R=302 (temporary) or R=301 (permanent) in the rewrite rule, but not R=300

Regards


thanks I will try this .


All times are GMT -5. The time now is 06:06 AM.