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

RewriteRule在服务器端和本地主机之间返回不同的结果

  •  1
  • alexis  · 技术社区  · 7 年前

    RewriteEngine On
    RewriteRule ^(contact)$ /test\.php?view=$1 [QSA,L]
    

    因此,在服务器端,我会显示以下页面: example.com/contact

    RewriteRule ^index\.html$ /index\.php [QSA,L]
    

    有人知道这是什么导致的吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   anubhava    7 年前

    将规则更改为:

     RewriteRule ^(contact)/?$ test.php?view=$1 [QSA,L,NC]
    

    这将重写 contact test.php 在您所在的目录中。htaccess保持不变。您的规则正在将同一请求重写为 由于前导导致的现场根 /

    /?$ on模式使尾部斜杠在请求URI中可选。