dqfaom241360 2012-06-24 23:27
浏览 41
已采纳

htaccess将所有流量重定向到非图像文件到另一个站点,并将所有图像流量重定向到单个图像

I have a handful of sites I am taking down for a while due to a recent hosting company move, and my primary focus being shifted towards a large project else where, that will ultimately leave my sites down and out for awhile.

So what I need to at the least do is drop an htaccess file in all the domains in question and have all non image based traffic point towards a domain that will actually be up and running, a redirect 301 or whatever, and then have a similar logic applied to just images so I can have images being hosted elsewhere like old form posts point to a single image again on the same domain that will be up.

I need to do this because my server error logs are filling up 10k+ lines an hour due to all the 404 and file not found issues from the other domains. Actually Ideally I would like to point all traffic to one lone file, and then use that file to dump the errors in a database, but use that same file to serve a single image in the event that it was an image request.

Are either of these to logics possible?

  • 写回答

1条回答 默认 最新

  • doremifasodo0008008 2012-06-24 23:38
    关注

    The following should work:

    RewriteEngine on
    RewriteRule \.(jpg|jpeg|png|gif)$ http://yournewsite.com/imagetoshow.png [NC,L,R]
    RewriteRule (.*) http://yournewsite.com [R]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器