【问题标题】:Issue Calling PHP from HTML从 HTML 调用 PHP 的问题
【发布时间】:2011-08-31 15:08:19
【问题描述】:

我在php中写过这样的代码

<a href="http://localhost/contactus.html" title="CONTACT US" > CONTACT US</a>

正确的,它应该去htaccess文件,看看是否有任何重写。 我的 .htaccess 文件是

RewriteRule ^([^/]+).html /index.php?file=$1 [NC]

所以我想 contactus 应该是 $1 因此 file=contactus 它应该调用

http://localhost/index.php?file=contactus

但它没有发生。

我检查了 htaccess 重写工作正常并启用。

请帮忙。谢谢

【问题讨论】:

  • 检查你的 apache 日志文件,看看你遇到了什么错误
  • 另外,请尝试启用重写日志,以便您可以查看重写规则中发生的情况。该正则表达式试图避免匹配前导斜杠,但根据您匹配它的内容(并且您没有向我们展示),每个请求可能都有一个前导斜杠......
  • 首先,我运行localhost/index.php文件,因为有联系我们的链接,我点击它,然后转到localhost/contactus.html
  • Offcourse 没有contactus.html 文件,因此显示页面无法显示“您要查找的页面当前不可用。” .. 但我希望遵循 .haccess 规则,它应该将我重定向到 localhost/index.php?file=contactus
  • 尊敬的先生,请让我知道我应该发布更多信息

标签: php html scripting


【解决方案1】:

尝试:

RewriteRule ^(.*).html$ index.php?file=$1 [NC][L]

【讨论】:

  • 先生,我试过你的重写规则,但我无法调出localhost/index.php 文件,它说服务器繁忙错误。然后我尝试了旧的重写,它能够调出
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-25
  • 2011-07-19
  • 2014-07-04
相关资源
最近更新 更多