6

I have a joomla setup in my /home/joomla directory. I installed both Apache and Lighttpd i have configured Lighttpd to proxy only static files, and lighttpd is listening on port 81. Now what i want is

whenever request for static files are made, instead of going to

www.domain.com/whatever/bg.jpg

it should redirect to

domain.com:81/whatever/bg.jpg

using .htaccess

also notice that www.domain.com changed to domain.com

please please i need a quick help for it :)

Subho Halder
  • 1,497
  • 4
  • 16
  • 30
  • Can you explain why you want to do this? Hosting the static files by both Apache and Lighttpd has no advantage that I can think of. It just makes it heavier for the server and thus slower. – Wolph Jul 11 '10 at 10:47
  • i am just relaying all static files through lighttpd, i have also made configuration to not to parse any dynamic content, such as php or html, cause they are already served by apache. instead all the images, videos etc, are being parsed from lighttpd , now incase some static content fails to obey htacces, because of the SEF system in Joomla, then the failsafe method of serving it through apache is also present :) Am i doing correct?? – Subho Halder Jul 11 '10 at 19:32
  • also i have tried using RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC] RewriteRule \.(jpg|jpeg|png|gif|css)$ http://domain.com:81/$1 [P,QSA,L] but it returns 404 not found error, :( – Subho Halder Jul 11 '10 at 20:17

2 Answers2

7

Alright i found out the way :)

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule \.(jpg|jpeg|png|gif|css)$ http://domain.com:81/$1 [P,QSA,L]

Learned a lot about htaccess files in one day :)

Subho Halder
  • 1,497
  • 4
  • 16
  • 30
0

try this in your .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(directory)
RewriteRule ^(.*)$ http://domain.com:81/$1 [P,QSA,L]
Ahmed Aman
  • 2,373
  • 1
  • 19
  • 33
  • I want only static files which is not neccesarily present in a directory, rewrite codition must check for jpg, css, flv, gif, etc and if itsz true then " RewriteRule ^(.*)$ http://domain.com:81/$1 [P,QSA,L] " – Subho Halder Jul 11 '10 at 19:36
  • even if i change the above to RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC] RewriteRule \.(jpg|jpeg|png|gif|css)$ http://domain.com:81/$1 [P,QSA,L] It returns 404 error...... – Subho Halder Jul 11 '10 at 20:16