可以';t使用.htaccess url重写时访问$_GET


can't accessing $_GET when use .htaccess url rewrite

现在我想用.htaccess清理我的url这是我的.htaccess代码

RewriteEngine On RewriteRule ^([^/]*)/([^/]*)'.html$ /movies.php?id=$1&m=$2 [L]

其工作良好的

这是movies.php

<?php
if (!isset($_GET['m'])) {
    header("Location:index.php");
} else {
    $m = str_replace('_',' ',$_GET['m']);
}
echo $_GET['m'];
?>

问题是它每次都会将页面重定向到index.php

.htaccess应该是

RewriteRule ^movies/([^/]+)/([^/]+)/?.html$ movies.php?m=$2&id=$1 [NC,L,QSA]

您的代码在条件的其他部分除了设置$m变量之外什么都不做,但我看不出在代码的其他地方使用了这一点。你可能打算做这样的事吗?

<?php
if(!isset($_GET['m'])){  
    header("Location:index.php");  
} else {
    $m = str_replace('_',' ',$_GET['m']);  
}  
echo $m; ?>