.htaccess having issue with RedirectMatch

2019-08-05 03:29发布

问题:

I have a site where I need to redirect from one url to another.

The current url: www.somesite.com/people/johndoe/?id=10

The desired url: www.somesite.com/people/?id=10

I am trying this in my .htaccess file but to no avail:

RedirectMatch ^/people/(.*)$ /people/?id=$1

This returns:

www.somesite.com/people/?id=johndoe

I have looked up many similar questions on this site and elsewhere, but cannot find a solution that works. Thanks in advance

回答1:

Your regex is not correct.

Use this:

RedirectMatch ^/(people)/.+$ /$1