LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-21-2013, 02:14 AM   #1
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 168

Rep: Reputation: 1
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 .
 
Old 03-21-2013, 03:56 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,910

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
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
 
1 members found this post helpful.
Old 03-21-2013, 03:58 AM   #3
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 168

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by bathory View Post
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 .
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
apache rewrite rule sunlinux Linux - Newbie 5 11-14-2011 07:06 AM
apache rewrite rule sunlinux Linux - Newbie 10 11-11-2011 05:01 AM
apache rewrite rule sunlinux Linux - Server 2 09-25-2011 02:03 PM
png/jpg text files? phantom_cyph General 1 04-05-2007 12:43 PM
jpg files has no preview in file tips, png does. Acidx Linux - Desktop 1 10-15-2006 01:52 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration