du8794 2018-05-22 12:18
浏览 50

PHP样式表链接

I am currently trying to use a HTML Diff Tool in php, more specifically this one: https://github.com/rashid2538/php-htmldiff I am downloading the page content of both pages using curl and pass it on to the HTML-Diff. It does the job perfectly the only problem is that in the result some amount of the linked css stylesheets are external and require a basic HTTP authentication, but the link element does not support url based authentication so simpy regexing in the credentials does not work e.g. http://user:pwd@some.url.com/sheet.css.

The only idea I have to remedy that is to search all stylesheet links with regex and replace them with their downloaded content. This seems really stupid and bad to maintenance to me, so is there any better way to do this?

  • 写回答

1条回答 默认 最新

  • dtvpl739577 2018-05-22 12:24
    关注

    You could use a proxy.

    @see this answer which uses a proxy in apache

    <Location /path>
        RequestHeader set Authorization "Basic <base64string>"
    </Location>
    
    ProxyPass /path http://backend/path
    ProxyPassReverse /path http://backend/path
    

    An alternative is something @apokryfos suggested. Furthermore, you might use the same diffing on the stylesheets as well. There are also libraries out there, where you can diff not only html. @see php-diff

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据