Automatically redirect nonexistent subdomains or folders… without plugins @ WordPress Help


What many people don’t know is that WordPress includes some specific features that can help your website’s SEO.

And something almost nobody knows is the file wp-config.php can also help us with SEO, in this case with Multi-Site Installations.

Concretely I mean that you can define a rule according to which: When a visit comes to a non-existent subdomain or subfolder on your site, you can automatically redirect it to a URL of your choice.

A practical example that I’m sure you’ll understand is when your domain is https://midominio.es and that for some reason, before you had a bunch of subdomains by language, you decided that another site would be the one welcoming users from other countries.

That is, where you were before https://en.midominio.es j https://fr.midominio.esnow all international traffic you prefer to reroute to https://midominio-internacional.com.

Note, of course, that this type of redirection doesn’t involve any variables. automatically redirects ALL subdomains and subfolders not present on the multisite to the url you specifiedas in the following example:

define( 'NOBLOGREDIRECT', 'https://midominio-internacional.com' );

From that moment on, any visit to a subdomain or a subfolder that does not exist in your multisite will be redirected to the url indicated in the constant, which of course you must change to the url you have chosen.

If you have a multi-site WordPress installation, this is practically essential code, since it is very common for subfolders and subdomains to be deleted, especially if it is an open multisite where you offer visitors to create blogs, such as e.g. wordpress.com. So it’s not only useful for special situations like in the first example.

If this code is not used, when visiting a nonexistent subfolder or subdomain, the user will be redirected to the registration page, indicating that the subdomain/subfolder does not exist.

Did you like this article? You have no idea what you’re missing a YouTube!



Source link

Related Posts

Leave a Reply

Open chat
Scan the code
Hello 👋
Can we help you?