使用 mod_rewrite
我(理想情况下)想从 RewriteCond
模式匹配的变量中的 URL 中捕获空间 ID(例如)
/index.php?option=com_content&view=article&id=984&Itemid=131
稍后在 RewriteRule
中使用它。
我在编写模式时没有问题,但无法确定这是否真的可行,尽管 reading the docs .有没有其他人尝试过或知道这是不可能的?
该站点建立在 Joomla 1.6 之上(它向 SEO 友好的 URL 添加了 ID),我试图避免像 HP Router 这样的开销。只是为了更改一组特定的 URL。
最佳答案
以下应该有效。您可以使用 %
符号从 RewriteCond
RewriteCond %{QUERY_STRING} Itemid=([0-9]*)$
RewriteRule (.*) /some/page/%1? [L,R=301]
希望这对您有所帮助。
关于apache - 是否可以从 Apache RewriteCond 模式匹配中捕获变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5627093/