代码之家  ›  专栏  ›  技术社区  ›  swamprunner7

Apache mod重写重定向

  •  0
  • swamprunner7  · 技术社区  · 15 年前

    我需要做:

    测试网站 main.com/check.php ,检查某物并返回 测试网站

    .htaccess访问:

    RewriteCond %{HTTP_HOST} !^main\.com$ [NC]
    RewriteRule ^(.*)$ http://main.com/check.php?url=%{HTTP_HOST}%{REQUEST_URI} [L]
    

    检查.php

    header("location: http://" . $_GET['url']);
    

    但它在循环。

    2 回复  |  直到 15 年前
        1
  •  1
  •   Community Mohan Dere    9 年前

    最佳选择 Sharing sessions across domains

    确定选项 Single sign on 系统。

    顽固的选择 RewriteCond 取消循环的资格。例如,尝试添加: RewriteCond %{QUERY_STRING} !*some string* [NC, OR] 在@nerkn建议的顶部(当然还有在check.php中发送一个查询字符串)。

        2
  •  0
  •   nerkn    15 年前

    RewriteCond %{HTTP_REFERER} !main\.com [NC, OR]
    RewriteCond %{HTTP_HOST} !^main\.com$ [NC]
    RewriteRule ^(.*)$ http://main.com/check.php?url=%{HTTP_HOST}%{REQUEST_URI} [L]
    
    推荐文章