htaccess redirect url with .html + a directory after it

We have a few odd formed urls that we're trying to redirect. They all look like this but with different 5 letters after the .html, this is how I tried making the redirects work:

redirect 301 /woodinville-carpet-cleaning.html/UPfMZ/ https://andersoncarpetcleaninginc.com/professional-home-carpet-cleaning-services-woodinville/

They won't redirect though. All the normal urls in the htaccess redirect just fine, so I know there isn't an issue in the file itself. Anyone have a solution to make them redirect as we expect?

Thanks for any help.
LVL 14
DzynitAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Terry WoodsIT GuruCommented:
Firstly, when you're testing redirects, use a 302 (temporary redirect) instead of a 301 (permanent redirect, which gets cached by the user's browser). Once you've got it working to your satisfaction, that's the time to change it to a 301.

If you do something wrong with a 301 redirect on a public site, you can (semi) permanently send your traffic elsewhere, with no way of undoing the damage.
0
Terry WoodsIT GuruCommented:
Try browsing to /woodinville-carpet-cleaning.html/UPfMZ/ instead of /woodinville-carpet-cleaning.html/UPfMZ and see if that works.

You could try changing it to:
redirect 302 /woodinville-carpet-cleaning.html/UPfMZ https://andersoncarpetcleaninginc.com/professional-home-carpet-cleaning-services-woodinville/

Open in new window

0
DzynitAuthor Commented:
No, that didn't work either. Thanks for trying. We're pretty sure those few were from a long time ago when the site was hacked, so it's ok if the redirects can't be made to work, but it did really get me interested in how to make it work if we needed to deal with it elsewhere.
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Terry WoodsIT GuruCommented:
Have you tried using a RedirectMatch (allows a pattern, for matching) or a RewriteRule?
0
Terry WoodsIT GuruCommented:
RewriteRule /woodinville-carpet-cleaning.html/UPfMZ/? https://andersoncarpetcleaninginc.com/professional-home-carpet-cleaning-services-woodinville/ [R=302,L]

Open in new window

0
Terry WoodsIT GuruCommented:
One thing that could stop it working is if your rule is below another rule in your htaccess file that redirects somewhere else. ie in that case the rule you're trying to use would never get reached.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.