htaccess url重定向问题

时间:2014-10-15 19:12:09

标签: php apache .htaccess mod-rewrite

我有一个htaccess(apache)文件,它具有以下规则:

RewriteEngine on
RewriteRule questionnaire/login questionnaire/login.php
RewriteRule questionnaire/logout questionnaire/logout.php
RewriteRule questionnaire/account questionnaire/account.php
RewriteRule questionnaire/reopen/id/[(^/]+)$ questionnaire/reopen_questionnaire.php?id=$1 [L]
RewriteRule questionnaire/register questionnaire/register.php
RewriteRule questionnaire/registration questionnaire/registration.php

当我运行我的网站时,它会给我以下错误:服务器遇到内部错误或配置错误,无法完成您的请求。

当我删除此行时:RewriteRule questionnaire/reopen/id/[(^/]+)$ questionnaire/reopen_questionnaire.php?id=$1 [L]它工作正常,有人可以告诉我为什么会这样做吗?

2 个答案:

答案 0 :(得分:1)

您未正确嵌套代码:

RewriteRule questionnaire/reopen/id/[(^/]+)$ questionnaire/reopen_questionnaire.php?id=$1 [L]

应该是:

RewriteRule questionnaire/reopen/id/([^/]+)$ questionnaire/reopen_questionnaire.php?id=$1 [L]

问题出在括号内 - > "()"

答案 1 :(得分:0)

尝试更改为:

RewriteRule questionnaire/reopen/id/([A-Za-z0-9-]+)/?$ questionnaire/reopen_questionnaire.php?id=$1 [L]