Arnie
Arnie

Reputation: 681

Redirect one URL to another using regex?

I want to redirect all requests to http://www.example.com/category/* to http://www.example.com.

This is what I tried:

RewriteRule http://www.example.com/category/.* http://www.example.com [R=301,L]

Unfortunately, this does not work. Any ideas how to write the rule correctly?

Thanks!

Upvotes: 2

Views: 47

Answers (2)

Croises
Croises

Reputation: 18671

You can use:

RewriteEngine on
RewriteRule ^category/ /? [NC,R=301,L]

Upvotes: 3

Manish
Manish

Reputation: 33

Please try below thing.

RewriteEngine on

RewriteRule "http://www.example.com/category/.*" "http://www.example.com" [PT]

Upvotes: 0

Related Questions