By being foolish I have caused several thousand pages to be listed in google with the wrong url
Example http://www.mysite.com/files/abc123/
Should be listed as
Example http://www.mysite.com/files/file-abc123/
Is there a way to 301 redirect them without affecting other files in that directory?
This is what I’ve been trying but no success so far
- Code: Select all
# If file has required ending
RewriteCond %{REQUEST_URI} files/(.+)/\$
# and does not start with file-
RewriteCond %{REQUEST_FILENAME} !^files/file-
# Redirect to file of same name in files
RewriteRule ^(.*)$ http://www.mysite.com/files/file-$1 [R=301,L]