I am managing a wordpress blog and want to throw a 404 error whenever the url contains a string pattern (example: if the url contains “thisisnotwanted”). I was thinking I will be able to add something to the htaccess file like: Redirect “thisisnotwanted” 404
Can someone help? I just don’t want Google to index pages with this parameter.
This could be achived using robots.txt but since you’re asking how to throw the 404 page manualy here it is :
This bit of code is just an example on how you can display a 404 page, and it shouldn’t be used in “production”, instead use robots.txt as Michiel Pater sugested .