Reputation: 85
I set up a new website with WordPress. But Google still has a sitelink to a no longer existing page with a URL parameter: domain.com/index.php?lang=EN which points to a non-existent page and should therefore throw a 404 error. But somehow WordPress does show a page stating
No blog posts have been added yet.
Due to not responding with a 404 error, the site does not disappear from Google Search Results!
How can I redirect incoming traffic from those two URLs:
to a 404 page? (I have set up a custom 404 page and added the ErrorDocument 404 in my .htaccess-file.)
Upvotes: 4
Views: 2541
Reputation: 786001
Add this rule on top of your .htaccess just below RewriteEngine On
line:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?lang=(EN|DE)\s [NC]
RewriteRule ^ - [R=404,L]
Upvotes: 2