• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Where in Plesk can I configure 301 redirect for non-existing subdomains?

olegos76

New Pleskian
Server operating system version
Rocky Linux 8.10
Plesk version and microupdate number
18.0.62 Update #1
Hello guys.
I am in quite a pickle here :) Please help!

Initial Problem: Google and Yandex robots keep finding subdomains that do not exist!

My server config:
Linux with Plesk Obsidian Web Host Edition - Version 18.0.62 Update #1
Site works in Laravel
Main site is https://mysite.com

... and 3 subdomains that I occasionally use:


BUT Google and Yandex reporting that these subdomains are also found:

I have no idea what they are and would love to get rid of them (or at least hide them from indexing by search engines)
Their own recommendation is to setup redirect 301 to my main site.

What brings complexity, is that I am running my server in: Nginx proxies requests to Apache mode.

Google says that in this case I don't need to make changes to .htaccess, but add the following to my nginx configuration:

server {
listen 80; # Adjust port if needed
server_name ~^(?!(dev|blog)\.).*\.yoursite\.com$; # Negative lookahead to exclude specific subdomains

# Redirect all other subdomains to your main website
return 301 https://yourdomain.com/;
}

Question 1: is this correct?
Question 2: if so, where in Plesk should I stick this code in?
(I tried placing it into "Additional nginx directives" field, but got an error: "Invalid nginx configuration: nginx: [emerg] "server" directive is not allowed here"

Please advise something...

Thank you!
 
Wouldn't be easier to remove any DNS records for those non used sub domains? Or in case your are using a wildcard DNS record to remove that and use specific DNS records instead?

Be aware though that by default mail. records get created which gets used for MX records. You can remove the mail. records, in which case you need to point your MX records to somewhere else too (the root domain for example).
 
Wouldn't be easier to remove any DNS records for those non used sub domains? Or in case your are using a wildcard DNS record to remove that and use specific DNS records instead?

Be aware though that by default mail. records get created which gets used for MX records. You can remove the mail. records, in which case you need to point your MX records to somewhere else too (the root domain for example).
Thank you! Will try this.
 
Back
Top