开发者

301 htaccess redirect dynamic url help needed

I'm trying to redirect this

hhttp://www.website.net/forum/index.php?showtopic=12345

to

hhttp://www.website.ORG/forum/t12345

12345 being the dynamic topic ID

I also need any information to be stripped away if it is found after the topic ID, for example

hhttp://www.website.net/forum/index.php?showtopic=12345&view=getlastpost

I want &view=getlastpost or any similar that may appear after the ID number to be get rid of.

I've tried

RewriteCond %{QUERY_STRING} ^(([^&]&))showtopic=([^&]+)&?(.*)?$ RewriteRule ^index.php$ http://www.website.org/forum/t%3?%1%4/ [L,R=301]

but it didn't work. I get trash in the URL.

hhttp开发者_开发问答://www.website.org/forum/index.php?showtopic=29294&view=getlastpost (when that link is clicked - the result is hhttp://www.website.net/forum/t29294?view=getlastpost/)

hhttp://www.website.org/forum/index.php?showtopic=29029 (when that link is clicked - the result is hhttp://www.website.net/forum/t29029?/).

How can I clear it out?


$2 implies there are two bracketed areas, but I only see one in your rule, so changed that to $1.

Also your URL starts /forum/ so need to include that in the rule.

And the . in index.php needs to be escaped if you don't want it treated as a regex special character.

And if you want to ditch anything after the showtopic=1234 then just remove the $ that indicates the end of the string

RewriteRule ^forum/index\.php?showtopic=([0-9]*) http://www.website.org/forum/t$1/ [L,R=301]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜