.htaccess rewrite to another port

六月ゝ 毕业季﹏ 提交于 2019-12-22 07:57:23

问题


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


回答1:


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




回答2:


try this in your .htaccess file:

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


来源:https://stackoverflow.com/questions/3222725/htaccess-rewrite-to-another-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!