我需要一个简单的正则表达式来匹配asp页面并将它们重定向到另一个页面。
例如
/showdetails.asp?id=1334至
/page-redirect.php?page=showdetails&id=1334这就是我到目前为止所拥有的,似乎不起作用
RedirectMatch 301 ^/(.*)\.asp?id=(.*)$ /page-redirect.php?page=$1&id=$2何地as
RedirectMatch 301 ^/(.*)\.asp$ /page-redirect.php?page=$1确实很管用。
不用担心自己解决了,需要逃避吗?
RedirectMatch 301 ^/(.*)\.asp\?id=(.*)$ /page-redirect.php?page=$1&id=$2发布于 2014-02-13 11:03:16
使用RedirectMatch指令,无法匹配查询字符串,因此所建议的解决方案都无法工作。
您需要使用基于mod_rewrite的规则。
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
RewriteRule ^([^.]+)\.asp$ /page-redirect.php?page=$1&id=%1 [L,NC,R=301]发布于 2014-02-13 09:52:53
你的
301 ^/(.*)\.asp?id=(.*)$ /page-redirect.php?page=$1&id=$2对,是这样
301 ^/(.*)\.asp\?id=(.*)$ /page-redirect.php?page=$1&id=$2考虑一下
301 ^/([^/]+)\.asp\?id=(\d+)$ /page-redirect.php?page=$1&id=$2发布于 2014-02-13 09:54:16
也许可以逃避? in asp?id。
https://stackoverflow.com/questions/21750523
复制相似问题