I'm trying to make a redirect with
Let's say that I have two websites:
What I want to do is redirect old to new with
random_file.html renamed to
Example how I would like it to work:
http://www.oldsite.example/shop.html?some_string_to_pass would redirect to
So far I came up with something like this:
RewriteEngine on RewriteRule ^([^/]+).html?(.*)$ /$1/$2 [R=301,L] RewriteRule ^(.*)$ http://www.newsite.example/$1 [R=301,L]
But it doesn't seam to work as I planned.
The first rule takes care of the
file.html and redirects it to
/file/ but only in main directory of the site.
When I try to enter:
http://www.oldsite.example/shop/product.html, I get:
http://www.oldsite.example/shop/product.html instead of the
http://www.oldsite.example/shop/product/ that I wanted.
Is there any option for it to work on all of the directories? What am I missing?
And is it possible to combine those rules together? Because the second rule does not work when I place it after the first one and it does not delete the
.html when on first position.