htaccess的重定向未完成任务未完成、重定向、任务、htaccess

2023-09-02 11:27:48 作者:不可触及ii

这是前两天我问一个问题,不能回答的我几乎都有,但不大,我敢肯定,这是我丢失的东西,你们能不能帮我...

A couple of days ago I asked a question that could not be answer an I almost have it but not quite, I'm sure that it’s something I'm missing and you guys can help me...

下面是code:

    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

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

The problem is that it does redirect but for some reason the redirect stops at the ? sign so it’s not completing the task.

希望我是决策意识这个时候。

Hope I’m making sense this time.

推荐答案

您不能对查询字符串匹配重写规则,你只能对%{QUERY_STRING} 内重写条件变量。该您已经于您的前pression被评价为​​在PHP最后一个P是可选的。但既然你似乎并没有被使用的查询字符串反正。删除所有标记。默认情况下,查询字符串被添加到您的规则的目标:

You can't match against the query string in a rewrite rule, you can only match against the %{QUERY_STRING} variable inside a rewrite condition. The ? you have in your expression gets evaluated as the last "p" in "php" is optional. But since you don't seem to be using the query string anyways. Remove all the ? marks. By default the query string is appended to the target of your rule:

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]