RedirectMatch不工作在htaccess的工作、RedirectMatch、htaccess

2023-09-02 11:40:49 作者:残缺的温柔

荫试图从

从 http://domain.com/article.php?id=23232   到 http://domain.com/article/23232

我使用这个语法在.​​htaccess

am using this syntax in .htaccess

RedirectMatch 301 article.php?id=(.*)$ http://domain/article/$1

所以请什么是这个错误?

so please what is the error in this?

推荐答案

你不能使用匹配查询字符串 RedirectMatch 。使用的mod_rewrite 规则,而不是:

You cant match query string using RedirectMatch. Use mod_rewrite rules instead:

RewriteCond %{QUERY_STRING} ^id=([^&]*)
RewriteRule ^article.php$ http://domain.com/article/%1? [L,R=301,NC]