DasSaffe
DasSaffe

Reputation: 2198

htaccess redirect only certain paths

Is it somehow possible (I guess it is) to redirect request something like this:

mysite.com/cat1 => mysite.com/my/full/link

mysite.com/cat1/product1 => mysite.com/cat1/product1

It is kinda hard to explain, but that pretty much sums it up.

In other words:

if someone enters example.com/cat1 he should be redirected to example.com/another/link (i have the full path ready to insert)

i tried the following:

Redirect 301      /cat1/    http://www.example.com/my/full/link

that didn't work

Then i tried it with a regexp as well:

RewriteCond ^(.*)example.com\cat1\[NC]
RewriteRule ^(.*)http://www.example.com/my/full/link/ [L,R=301]

Upvotes: 1

Views: 56

Answers (1)

anubhava
anubhava

Reputation: 785156

You can use this RedirectMatch rule since it has regex capabilities unlike Redirect:

RedirectMatch ^/cat1/?$ http://www.example.com/my/full/link

Upvotes: 1

Related Questions