17

I recently notice bad URLs coming from external sites to my site.

I get a lots of 404 not found from sites that reference my site using a bad link like:

My site - http://www.example.com/mypage/CachedOnTuesdays

My link should be: http://www.example.com/mypage/

I know I cannot ask them to fix it. Is there a way for me to remove the last part of the URL to display the correct page?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Erin Tucker
  • 3,274
  • 2
  • 15
  • 22
  • The easiest solution I could think of is uses PHP. Is that an option? Next best choice would be JavaScript. – Dennis Oct 28 '11 at 11:24

1 Answers1

23

Use this:

RewriteEngine On
RewriteRule ^(.*)/CachedOnTuesdays$ http://www.example.com/$1 [R=301,NC,L]
Cœur
  • 37,241
  • 25
  • 195
  • 267
Tech4Wilco
  • 6,740
  • 5
  • 46
  • 81