【问题标题】:.htaccess for clean URL not working.htaccess 的干净 URL 不起作用
【发布时间】:2009-11-07 05:58:02
【问题描述】:

我是第一次使用 PHP 和 htacess。我将查询字符串中的变量传递给 URL,并希望该 URL 看起来干净。请帮忙。
.htaccess 文件

RewriteEngine On
RewriteRule ^id-([0-9]+)/([0-9A-Za-z]+).html  /detail.php?id=$1&display=$2

从一个文件到详细页面 URL 的 PHP 代码是:

<a href='/detail.php?id={$info[id]}&display=$title1'>

请帮忙。

【问题讨论】:

  • 究竟什么是行不通的,你到底想达到什么目标?
  • 能否添加一个类似于 RewriteRule 指令左侧的 URL 示例?

标签: php apache .htaccess mod-rewrite url-rewriting


【解决方案1】:

您需要打印出新的 URL 才能被 mod_rewrite 重写。因为 mod_rewrite 只能重写请求的 URL。所以试试这个:

<a href='/id-{$info[id]}-$title1.html'>

【讨论】:

猜你喜欢
  • 2014-12-13
  • 2014-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-06
  • 2016-04-24
  • 2014-02-09
相关资源
最近更新 更多