Reputation: 4058
I have the following rewrite rule in my .htaccess
file:
Redirect 301 /products http://example.com/products.html
Which works fine, however it's affecting the URLs of the files inside the folder so:
http://example.com/products/item.html
Gets redirected to:
http://example.com/products.html/item.html
Is there any way that I can only target the parent folder with my redirect and not the files inside it?
Upvotes: 1
Views: 290
Reputation: 784998
Is there any way that I can only target the parent folder with my redirect and not the files inside it?
Yes use RedirectMatch
for precise targeting using a regex:
RedirectMatch 301 ^/products/?$ http://example.com/products.html
Regex ^/products/?$
will match /product
or /product/
but NOT /product/file
.
Upvotes: 1