htaccess重定向到哪里index.php?存在


htaccess redirect where index.php? exists

我一直觉得htaccess是一门黑色艺术:)

我有一个由CMS提供支持的网站,它的url中有index.php。我通常的htaccess是标准的,足以删除它。

然而,从历史上看,该网站有一个离线的URLhttp://domain.org/index.php?/resources/name-索引/a/steven

但是,此URL已不存在,应该指向http://domain.org/pages/steven

除了其他重定向,我还添加了

RewriteRule ^resources/name-index/a/steven http://domain.org/pages/steven

然而,当我击中http://domain.org/index.php?/resources/name-index/a/steven,但是,如果我们命中http://domain.org/resources/name-index/a/steven它会按照您对新页面的期望进行重写。

忍不住想的存在吗?url中的index.php正在对规则造成严重破坏,或者index.php正被上面的另一条规则删除(本以为这无关紧要)。

欢迎提出建议。

将此代码放在htaccess(应该在根文件夹中)的开头

RewriteEngine On
RewriteCond %{QUERY_STRING} ^/resources/name-index/a/steven$ [NC]
RewriteRule ^index'.php$ /pages/steven? [R=301,L]