1

我正在尝试在.htaccess 中编写重写规则。到目前为止,它一直运行良好。但是今天,我尝试编写一个规则,并且变量中有特殊字符(-)。像这样的东西

http://127.0.0.1/website/client/ticket/update/KU0-QMV-882Q/

KU0-QMV-882Q是变量。

我的重写规则如下

# This Directive will make Apache look first  

Options +FollowSymLinks

RewriteEngine on

RewriteRule ^orders/pending$ orders.php?type=pending

RewriteRule ^orders/completed$ orders.php?type=completed

RewriteRule ^logout$ logout.php

RewriteRule ^login$ login.php

RewriteRule ^ticket/open$ open-ticket.php


RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 

RewriteRule ^ticket/update/(\w+)$   update-ticket.php?ticket_no=$1 

现在,当我尝试访问 URL 时,它会出现 404 NOT Found 错误。

那么我需要在 .htaccess 文件中写些什么呢?

在此先感谢您的帮助。

问候, 普拉蒂克 G

4

1 回答 1

3

在您的规则\w+中,表示每个字母、数字和下划线,但不是连字符。你应该[\w-]+改用。

于 2013-08-23T11:04:15.930 回答