• I wondered if it’s possible to set the default homepage in a different URL apart from the root route.

    For example:

    https://example.com/home/

    And https://example.com is a 404

    If I set static home page in Reading then it will become the new root.

    If I leave it unset, then blog archive will be the home.

    So I cannot figure out a solution to this.

Viewing 1 replies (of 1 total)
  • Generally whatever you define under Reading as your homepage, is what’s going to load at the root of your domain.

    To force a WordPress error page to come up, leave your Reading set to something like Your latest posts, and add the following code either to a plugin or your theme:

    add_action('template_redirect', function () {
        if (!is_home()) return;
        global $wp_query;
        $wp_query->set_404();
        status_header(404);
    });

    If the page requested is anything other than home, WordPress will operate normally, however if the user requests the homepage, it will force a 404 error page.

Viewing 1 replies (of 1 total)
  • The topic ‘Default Homepage in a URL’ is closed to new replies.