开发者

old url not working in .htaccess

开发者 https://www.devze.com 2023-02-18 14:14 出处:网络
I have updates the system on my website and so i want to do some redirects for links to the new pages .

I have updates the system on my website and so i want to do some redirects for links to the new pages .

i am trying the following rewriterule ^jor/index.php?option=com_content&task=view&id=([0-9])&Itemid=([0-9])$ index.php?page=article&开发者_Go百科amp;id=$1

but it's not working . just an 'invalid link' .

and how to make it 302 redirect ?

Thanks


You can't match the query string directly with RewriteRule; it will only match the file path. You need to use RewriteCond and %1 (rather than $1)

RewriteCond %{QUERY_STRING} id=([0-9]+)&Itemid=([0-9]+)$
RewriteRule ^jor/index.php index.php?page=article&id=%1&itemid=%2 [R=302,L]

Note a few things:

1) It's assumed that id is followed by itemid which is followed by the end of the string. itemid=1337&id=42 will not work because the order is swapped.

2) The rule makes no assumptions about the rest of the query string. It could just as well begin with option=com_radio.

3) Note the + after [0-9] which is needed to match more than one character. (+ means "one or more")

0

精彩评论

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