htaccess redirect url with .html + a directory after it

Dzynit
Dzynit used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Terry WoodsIT Guru
Most Valuable Expert 2011

Commented:
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.
Terry WoodsIT Guru
Most Valuable Expert 2011

Commented:
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

Author

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.
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Terry WoodsIT Guru
Most Valuable Expert 2011

Commented:
Have you tried using a RedirectMatch (allows a pattern, for matching) or a RewriteRule?
Terry WoodsIT Guru
Most Valuable Expert 2011

Commented:
RewriteRule /woodinville-carpet-cleaning.html/UPfMZ/? https://andersoncarpetcleaninginc.com/professional-home-carpet-cleaning-services-woodinville/ [R=302,L]

Open in new window

IT Guru
Most Valuable Expert 2011
Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial