I want to redirect many URLs in my shop. Here is the example:
/pl/index/12
/pl/index/16
/pl/index/18
and so on.
What would be the rule for .htaccess to rewrite all of trash URLs from the previous version of shop to my main page?
I want to redirect many URLs in my shop. Here is the example:
/pl/index/12
/pl/index/16
/pl/index/18
and so on.
What would be the rule for .htaccess to rewrite all of trash URLs from the previous version of shop to my main page?
As stated by Stephen, you should rather set a 410 Gone
redirection, like this:
# /.htaccess:
Redirect 410 /pl/index/12
Redirect 410 /pl/index/16
Redirect 410 /pl/index/18
# And so on.
Or, if you can identify a pattern in the paths that have to be redirected, you can use the RedirectMatch
directive, for example:
# /.htaccess:
# Of course, you **must** adapt this regex to your case.
RedirectMatch 410 ^/pl/index/1[2|6|8]$
If you can identify a pattern in your paths and want to "410-redirect" the users to a specific page explaining what happens with these gone pages, you can use RewriteRule
:
# /.htaccess:
# Of course, you **must** adapt this regex to your case.
RewriteRule ^pl/index/1[2|6|8]$ /special-error410-page.html [R=410,L]
Redirect 410 /pl
which would capture everything in the directory. Or they might want the regex: ^/pl/index/[0-9]+$
which would match any numbers in place of of their three example numbers.
Commented
May 23, 2020 at 10:49