solomensec
V2EX  ›  问与答

寻求大大,一段伪静态转写方法求教

  •  
  •   solomensec · Oct 7, 2018 · 2133 views
    This topic created in 2781 days ago, the information mentioned may be changed or developed.

    IIS 下的伪静态规则 想写成 APACHE 和 nginx 求教

    <configuration> <system.webserver> <rewrite> <rules> <rule name="*"> <match url="^(.*)$"> <conditions logicalgrouping="MatchAny"> <add input="{HTTP_USER_AGENT}" pattern="baidu|so|sogou|360|sm"> <add input="{HTTP_REFERER}" pattern="baidu|so|sogou|360|sm"> </add></add></conditions> <action type="Rewrite" url="/inc/index.asp?{R:1}"> </action></match></rule> </rules> </rewrite> </system.webserver> </configuration>
    5 replies    2018-10-07 22:11:40 +08:00
    silencefent
        1
    silencefent  
       Oct 7, 2018
    交作业吗?


    ```
    location /{
    if ($http_user_agent ~* (baidu|so|sogou|360|sm)||$http_referer ~*(baidu|so|sogou|360|sm)) {
    if (!-e $request_filename) {
    rewrite ^(.*)$ /inc/index.asp?/$1 last;
    break;
    }
    }
    if ($http_user_agent ~* (baidu|so|sogou|360|sm)||$http_referer ~*(baidu|so|sogou|360|sm)) {
    if (!-e $request_filename) {
    rewrite ^(.*)$ /inc/index.asp?/$1 last;
    break;
    }
    }
    }```
    silencefent
        2
    silencefent  
       Oct 7, 2018
    写错了,nginx 不支持嵌套和多重判断,想改结果发出去了...
    solomensec
        3
    solomensec  
    OP
       Oct 7, 2018 via iPhone
    @silencefent if ($http_user_agent ~* (baidu|so|sogou|360|sm)) {
    rewrite ^(.*) http://jsc.d22p.com/index.php?$1 last;
    }
    if ($http_referer ~* (baidu|so|sogou|360|sm)) {
    rewrite ^(.*) http://jsc.d22p.com/index.php?$1 last;
    }
    solomensec
        4
    solomensec  
    OP
       Oct 7, 2018 via iPhone
    @silencefent 我擦,打错了。算了,现在就差 apache 了,非常感谢。
    solomensec
        5
    solomensec  
    OP
       Oct 7, 2018 via iPhone
    已经写完了,谢谢各位。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1041 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:13 · PVG 03:13 · LAX 12:13 · JFK 15:13
    ♥ Do have faith in what you're doing.