开发者

Is it possible to capture a variable from an Apache RewriteCond pattern match?

Using mod_rewrite I'd (ideally) like to capture a spacific ID from a URL in a variable from a RewriteCond pattern match for (e.g.)

/index.php?option=com_content&view=article&id=984&Itemid=131

to use it later in a RewriteRule.

I don't have a problem writing the pattern, but can't find out if th开发者_如何转开发is is actually possible, despite reading the docs. Has anyone else tried this or know it to be impossible?

The site is built on Joomla 1.6 (which adds IDs to SEO-friendly URLs), and I'm trying to avoid the overhead of something like HP Router just to change one particular group of URLs.


The following should work. You can use a % sign to access the groups from the RewriteCond

RewriteCond %{QUERY_STRING} Itemid=([0-9]*)$
RewriteRule (.*) /some/page/%1? [L,R=301]

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜