【问题标题】:Can host be extracted from referer in mod_rewrite for htaccess / apache?可以从 mod_rewrite 中的引用者中提取主机以用于 htaccess / apache 吗?
【发布时间】:2010-06-06 21:12:45
【问题描述】:

我正在尝试在需要 HTTP_REFERER 的主机部分的地方进行重写。

所以如果引用者是例如http://www.example.com/some/path 我需要提取主机部分,www.example.com 并在 RewriteRule 中使用它,以便它重写为 /some/serverpath/ www.example.com/subfolder.

这可能吗?

【问题讨论】:

    标签: apache mod-rewrite .htaccess


    【解决方案1】:

    试试这个:

    RewriteCond %{HTTP_REFERER} ^https?://([^/:]+)
    RewriteCond %{REQUEST_URI} !^/some/serverpath/
    RewriteRule ^ /some/serverpath/%1/subfolder
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-30
      • 2014-03-08
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      • 2013-07-25
      相关资源
      最近更新 更多