2013-04-25 33 views
1

几天前,我问了一个无法回答的问题,我几乎有它,但不是很确定,我相信这是我错过的东西,你们可以帮我...htaccess重定向不完整的任务

下面是代码:

RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^monitorbc\.info$ [OR] 
    RewriteCond %{HTTP_HOST} ^www\.monitorbc\.info$ 
    RewriteRule ^notas\.php?(.*) "https://monitorbc.info/monitor3/notas.php?" [R=301,L] 

    # one of the links from the old site = https://monitorbc.info/notas.php?id=699&sec=economia 
    # It should end up like this = https://monitorbc.info/monitor3/notas.php?id=699&sec=economia 

的问题是,它并重定向但由于某种原因重定向在停止?签署,所以它没有完成任务。

希望我这次有道理。

回答

1

在重写规则中,您无法与查询字符串进行匹配,因此只能在重写条件内与%{QUERY_STRING}变量匹配。您在表达式中的?会被评估为“php”中的最后一个“p”是可选的。但是,因为你似乎没有使用查询字符串。删除所有?标记。默认情况下,查询字符串附加到您的规则的目标:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^monitorbc\.info$ [OR] 
RewriteCond %{HTTP_HOST} ^www\.monitorbc\.info$ 
RewriteRule ^notas\.php$ https://monitorbc.info/monitor3/notas.php [R=301,L] 
+0

太好了。非常感谢,几天前我很抱歉这个问题非常严重。你的建议完美运作。 – 2013-04-25 09:58:29