Mod_rewrite - 重定向已经重写的 url

Mod_rewrite - redirecting an already rewritten url

我之前曾这样重写文章的URL:

RewriteRule ^([^/\.]+)/([^/\.]+)/?article_(.*)_(.*).html$ index.php?sectionpp=&sectionpp2=&content=article&artid=&curbigart= [L]

这产生了像这样的 url: http://www.domain.com/Entertainment/114194/VINYETTE-TO-RELEASE-DEBUT-ALBUM-ON-MAY-7-2013

但是,现在我重新设计了网站并缩短了 urls:

RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?sectionpp=&content=article&artid=&curbigart= [L]

生成 url 如下: http://www.domain.com/Entertainment/114194

问题: 是否可以重定向已经重写的 url http://domain.com/Entertainment/114194/VINYETTE-TO-RELEASE-DEBUT-ALBUM-ON-MAY-7-2013

http://domain.com/Entertainment/114194

显然我们不是在谈论单个页面,而是在谈论数千个页面,因此需要 .htaccess 中的一行,呵呵。我知道我可以简单地在 php 中重定向,但我认为在 .htaccess 中也必须有一种方法可以做到这一点?

谢谢!

Is it possible to redirect the already rewritten url domain.com/Entertainment/114194/VINYETTE-TO-RELEASE-DEBUT-ALBUM-ON-MAY-7-2013 to domain.com/Entertainment/114194

您可以将规则用作根 .htaccess 中的第一个规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w-]+/\d+)/.+$ / [L,R=302]