Link to home
Start Free TrialLog in
Avatar of Heather Ritchey
Heather RitcheyFlag for United States of America

asked on

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.
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

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.
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

Avatar of Heather Ritchey

ASKER

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.
Have you tried using a RedirectMatch (allows a pattern, for matching) or a RewriteRule?
RewriteRule /woodinville-carpet-cleaning.html/UPfMZ/? https://andersoncarpetcleaninginc.com/professional-home-carpet-cleaning-services-woodinville/ [R=302,L]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial