apache重写规则无法按预期工作

时间:2017-08-14 09:06:39

标签: php apache url-rewriting

以下是我的api.xxxx.com/notify/alipay to api.xxxx.com/mobile/index.php?act=notify&op=alipay 代码:

<table>

网址重写规则

<!DOCTYPE html>
<html>

<head>
  <title> Manan Tyagi 16BCE1240</title>

  <p style="text-align:center;color:purple;font-size:30px">Coordinates Of State Capitals</p>
  <p id="demo"></p>

  <script>
    var capital = ["Montgomery", "Juneau", "Phoenix", "Little Rock", "Sacramento", "Denver", "Hartford", "Dover", "Tallahassee", "Atlanta"];
    var state = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia"];
    var code = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA"];
    var latitude = [32, 58, 33, 35, 38, 40, 42, 39, 31, 34];
    var longitude = [-86, -134, -113, -92, -121, -105, -73, -76, -84, -84];
    var htmlstr = "<table><tbody>";
    for (var i = 0; i < 10; ++i) {
      htmlstr += "<tr>" + "<td>" + capital[i] + "</td>" + "<td>" + state[i] + "</td>" + "<td>" + code[i] + "</td>" + "<td>" + latitude[i] + "</td>" + "<td>" + longitude[i] + "</td></tr>";
    }
    htmlstr += "</tbody></table>";
    document.write(htmlstr);
  </script>
</head>

<body>
</body>


</html>

无效。任何人都可以解释我在这里做错了什么?感谢。

1 个答案:

答案 0 :(得分:0)

这一行RewriteRule . index.php将覆盖其后的任何内容。

如果你把那个放在最后那么它应该解决你的问题。

尝试像这样交换第8行和第9行:

<VirtualHost *:80>
        ServerName api.xxxx.com
        DocumentRoot /dianxiaoer/html/two-twenty
        <Directory /dianxiaoer/html/two-twenty>
                RewriteEngine on
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule /notify/alipay /mobile/index.php?act=notify&op=alipay [L]
                RewriteRule . index.php
                #Options Indexes FollowSymLinks MultiViews
                Options FollowSymLinks
                AllowOverride None
                Require all granted
                Order allow,deny
                allow from all
         </Directory>
</VirtualHost>

希望能解决您的问题。