1

这是原始网址:

http://myurl.com/entertainment/act-view.html?act_name=good-duo

我希望能够改为:

http://myurl.com/entertainment/good-duo

这是我正在尝试但得到 500 内部服务器错误

RewriteEngine On
RewriteRule ^entertainment/([^/]*)$ /entertainment/act-view.html?act_name=$1 [L]
4

1 回答 1

1

因为你的正则表达式是这样的,所以你因为循环而得到 500:

^entertainment/([^/]*)$

哪个在重写之前和之后匹配URI,即这些

/entertainment/good-duo
/entertainment/act-view.html

您可以使用此规则:

# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^entertainment/([^/]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC]

或这个:

RewriteRule ^entertainment/([^/.]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC]
于 2013-10-30T17:22:40.883 回答