.htaccess rewrite to another port.

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

whenever a request is made for static files, instead of going to

www.domain.com/whatever/bg.jpg

he should redirect to

domain.com:81/whatever/bg.jpg

using .htaccess

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

please i need quick help for this :)

+4
source share
2 answers

Ok, I found out how :)

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 :)

+5
source

try this in your .htaccess file:

 RewriteEngine on RewriteCond %{REQUEST_URI} ^/(directory) RewriteRule ^(.*)$ http://domain.com:81/$1 [P,QSA,L] 
0
source

Source: https://habr.com/ru/post/1315321/


All Articles