[英]htaccess redirect where index.php? exists
I've always found htaccess to be something a black art :) 我一直发现htaccess是一件卑鄙的事情:)
I have a site powered by a CMS which had index.php in the url. 我有一个由CMS支持的网站,该网站的URL中包含index.php。 My usual htaccess is standard enough to remove that.
我通常的htaccess足以将其删除。
However, historically, the site has a URL that's been offline http://domain.org/index.php?/resources/name-index/a/steven 但是,从历史上看,该站点的URL一直处于离线状态http://domain.org/index.php?/resources/name-index/a/steven
However, this URL no longer exists and should instead point to http://domain.org/pages/steven 但是,此URL不再存在,而应指向http://domain.org/pages/steven
Alongside the other redirects I added 我添加了其他重定向
RewriteRule ^resources/name-index/a/steven http://domain.org/pages/steven
However, when I hit http://domain.org/index.php?/resources/name-index/a/steven we get a 404, however, if we hit http://domain.org/resources/name-index/a/steven it rewrites as you'd expect to the new page. 但是,当我点击http://domain.org/index.php?/resources/name-index/a/steven时,我们会得到一个404,但如果我们点击http://domain.org/resources/name-index / a / steven会按照您期望的那样重写到新页面。
Can't help but think the existence of the ? 忍不住想了吗? in the url is wreaking havoc with the rule or the fact that index.php is being removed by another rule above (wouldn't have thought it would have mattered).
网址中的规则正在破坏该规则,或者事实是index.php被上面的另一个规则删除了(不会以为这会很重要)。
Suggestions welcomed. 欢迎提出建议。
Put this code in the beginning of your htaccess (which should be in root folder) 将此代码放在htaccess的开头(应位于根文件夹中)
RewriteEngine On
RewriteCond %{QUERY_STRING} ^/resources/name-index/a/steven$ [NC]
RewriteRule ^index\.php$ /pages/steven? [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.