LouJ
LouJ

Reputation: 47

htaccess redirect 301 and rewrite

I am trying to simplify URLs from

xyz.com/walks/walk_descrip/8010/ to xyz.com/walk-8010

I have moved the file from the walks sub-directory to the root.

I have tried using the following in my htaccess file

Redirect 301 ^/walks/walk_descrip/(.*)/$ /walk-$1
RewriteRule ^walk-(.*)$ /walk-description.php?id=$

However this is producing URLs such as

xyz.com/walk-8010?id=8010

Where am I going wrong?

Any help would be appreciated

Upvotes: 0

Views: 22

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

Redirect directive doesnt support regex. What you are looking for is RedirectMatch.

RedirectMatch 301 ^/walks/walk_descrip/(.+)$ /walk-$1 

Upvotes: 1

Related Questions