在php中重命名URL无法正常工作

时间:2012-07-25 11:20:39

标签: php .htaccess url-rewriting

我写的是:

RewriteRule ^title$  articles.php?&=stop [QSA,L,N,S=15]
RewriteCond %{QUERY_STRING} !stop 
RewriteRule articles.php? http://mysite.com/pages/title [r=301,L,nc]

pages/title?id_article=2重命名为pages/title

但它不起作用。 有什么建议吗? 提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果你想用PHP做,以下是脚本:

<?php
$url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$url = explode('?', $url);

if(!empty($url[1])) 
{
header("Location: http://".$url[0]);
}
?>