Home > Enterprise >  redirect numerous dynamic urls to home page via .htaccess
redirect numerous dynamic urls to home page via .htaccess

Time:04-06

I am trying to clean up a previously hacked WordPress site, and domain name reputation, the site has new hosting and is now on a different CMS system, but there are hundreds of spam links in Google I need to get rid of, they look like example.com/votes.php?10054nzwzm75042pw205039

Domain name, then votes.php?**** etc.. Numbers letters all sorts.

So how do I redirect ANYTHING that starts with the domain name then /votes.php?***

Any help greatly appreciated

CodePudding user response:

Unless you have multiple domains, you don't need to explicitly check the domain name.

To send a "410 Gone" for anything that contains /votes.php in the URL-path (and any query string), you can do something like the following at the top of your root .htaccess file using mod_rewrite:

RewriteEngine On

# Serve a 410 Gone for any requests to "/votes.php"
RewriteRule ^votes\.php$ - [G]

A 410 is preferable to a "redirect" if you want to get these URLs removed from the search engines as quickly as possible.

To expedite the process of URL removal from Google then use Google's Removal Tool as well.

If you redirect these pages to the homepage then it will likely be seen as a soft-404 by Google and these URLs are likely to remain in the search results for a lot longer.

  • Related