saikofish
saikofish

Reputation: 1754

Using htaccess to redirect a directory, but not the files in it

On my website, I've got a directory /folder with some images and html in it. I want to redirect users who try to access http://domain.com/folder to http://domain.com/ but don't want requests for the files in that directory to redirect to http://domain.com/ either. When I try

Redirect /folder http://domain.com/

it breaks the site because now it thinks all the images, etc are in the root directory when it is not. How do i fix this?

Upvotes: 1

Views: 3566

Answers (1)

Gumbo
Gumbo

Reputation: 655845

Use RedirectMatch instead:

RedirectMatch ^/folder$ http://example.com/

Now the URI path must exactly match /folder.

Upvotes: 5

Related Questions