Url重写:资源管理器找不到页面,但脚本被执行


url rewrite : explorer can't find the page but the script gets executed ?

这是我的原始URL,这是一个激活链接我将发送给用户的电子邮件来激活他们的帐户

www.m.com/activation.php?active=c663f71e95e242416488e0de7861db8f

我想把它改写成

www.m.com/activation/c663f71e95e242416488e0de7861db8f/

这是我的html代码:

^activation/([a0-z9]*)/$ activation.php?active=$1

是我的activation.php代码它将激活用户,然后将用户重定向到他/她的配置文件

<?php
$active_code = isset($_GET['active'])? $_GET['active'] : exit ;
$user = user::find_unactive_user($active_code);
if($user){
$user->active();
header('location:profile.php');
}else echo 'cant find user';
?>

现在奇怪的事情是,当我点击激活链接浏览器重定向到404错误页面,所以显然它不能找到给定url的页面但是用户状态将变为活动,这意味着脚本已被执行!

我做错了什么?

这是我的htaccess页面,以防万一

<Files ~ "^'.(htaccess|htpasswd)$">
deny from all
</Files>
Options Indexes
AuthUserFile .htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user 
order deny,allow
ErrorDocument 404 http://www.m.com/404.php
RewriteEngine On
# Rewrite numeric URLs
RewriteRule ^project-([0-9]*)-.*'.html$ project.php?project=$1 [L]
RewriteRule ^project-([0-9]*)'.html$ project.php?project=$1 [L]

RewriteRule ^activation/([a0-z9]*)/$ activation.php?active=$1 [L]

我认为你的url:

有错误<>之前^激活/((a0-z9) *)/$ activation.php ?积极= 1美元//应该^激活/((a-z0-9) *)/$ activation.php ?积极= 1美元

要纠正的事情:首先Regexp是无效的(见Sudhir),并且您忘记了QSA保留作为GET附加的东西,也许NC标志(=不区分大小写):

RewriteRule ^activation/([a-z0-9]*)/$ activation.php?active=$1 [NC,QSA,L]