我一直在努力获得以下重写工作
^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+)\?doc-id=([0-9a-zA-Z._\-]+)
至
/agateDepot.php?date=$1&filename=$2&doc-id=$3
我知道mod_rewrite正在工作。 我知道它正在读取.htaccess文件,我只是没有看到任何redirect发生。 这是我的.htaccess文件
RewriteEngine On RewriteRule ^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+)\?doc-id=([0-9a-zA-Z._\-]+) /agateDepot.php?date=$1&filename=$2&doc-id=$3
任何帮助将不胜感激。 我想这是简单的,但我一直没能弄明白。 Apache错误日志中没有错误,访问日志只是简单地logging一个404。
看来你正试图匹配“模式”中的查询string。 这不是正确的做法。
试试这个:
RewriteEngine On RewriteCond %{QUERY_STRING} ^doc-id=([0-9a-zA-Z._\-]+)$ RewriteRule ^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+) /agateDepot.php?date=$1&filename=$2&doc-id=%1?
我想你不得不在范围括号内出现这个点。 否则它匹配“任何东西”。 如果是这样,你的第一个捕获组将捕获所有可用的字符,其他捕获组将不会得到任何东西。
喜欢这个
^/agatedepot/([0-9\.]+)/([0-9a-zA-Z\._]+)\?doc-id=([0-9a-zA-Z\._\-]+)