1

Our site home page URL is https://example.com

But the corresponding CMS Page in Magento 2.4.4 has home as the URL Key.

As a result, the home page can also be browsed at https://example.com/home

We do not want to allow it.

Things we tried:

  1. Set the URL Key to empty
    • Result: This identifier is reserved for "CMS Home Page" in configuration.
  2. Set the URL Key to /
    • Result: This identifier is reserved for "CMS Home Page" in configuration.
  3. Set a URL Rewrite, from home to /
    • Result: Request Path for Specified Store already exists.

So what? Are we condemned to have the home page also browsable from an arbitrary URL?

asked Mar 21, 2023 at 12:46
2
  • im curious as to why this is an issue? your homepage is likely also browsable by the similarly arbitary example.com/index.php Commented Mar 23, 2023 at 14:35
  • @bjornredemption - I checked /index.php and it is not browsable; it results in 404 page. We use ScandiPWA theme, and it renders /home completely broken. We can't spend time/money fixing the broken rendering. If only we can redirect or just remove /home, our problem is resolved. Commented Mar 26, 2023 at 23:52

3 Answers 3

1

A couple of custom Fastly VCL snippets is what worked for us. (The store is hosted at Adobe's Magento Cloud.)

This configuration can be found at:

  • Magento admin > Stores > Configuration > Advanced > System > Full Page Cache > Fastly Configuration > Custom VCL Snippets

The "Redirects" documentation from Fastly helped on creating the specific necessary VCL snippets.

recv

if (req.url.path == "/home") {
 error 618 "redirect";
}

error

if (obj.status == 618 && obj.response == "redirect") {
 set obj.status = 301;
 set obj.http.Location = "https://" + req.http.host + "/";
 return (deliver);
}

See the solution at https://fiddle.fastly.dev/fiddle/74577b5a

Here are the screenshots from Magento admin:

recv snippet


error snippet


IMHO, this is insane. At least, our problem is resolved.

answered Mar 27, 2023 at 0:52
0

Set a redirect for the "/home" URL: set up a redirect for the "/home" URL to redirect users to the actual home page at "/". To do this, you can create a URL Rewrite in Magento 2.4.4.

In the Magento Admin, go to Marketing > SEO & Search > URL Rewrites, and create a new rewrite.

Set the Request Path to "/home", the Target Path to "/", and the Redirect Type to "Permanent (301)". Save the rewrite and test to see if it redirects users from "/home" to the actual home page.

Let know if you have any query.

Thanks

answered Mar 21, 2023 at 12:55
1
  • This does not work. As described in the question, this has been attempted, and results in error Request Path for Specified Store already exists. Commented Mar 21, 2023 at 18:29
0

It seems you want to prevent the home page from being accessible via https://example.com/home, while still keeping it accessible at https://example.com. To achieve this, you can set up a URL redirect using the URL Rewrite Management in Magento 2.

Here's how to create a custom URL Rewrite to redirect https://example.com/home to https://example.com:

  1. Log in to your Magento 2 Admin Panel.

  2. Navigate to Marketing > SEO & Search > URL Rewrites.

  3. Click on the "Add URL Rewrite" button.

  4. Select "Custom" from the "Create URL Rewrite" dropdown menu.

  5. Fill out the form with the following information:

  • Store: Choose the appropriate store view.
  • Request Path: home
  • Target Path: /
  • Redirect Type: Permanent (301)
  • Description: (optional) Redirect home to root
  1. Click on the "Save" button to create the URL rewrite rule.

Now, when someone tries to access https://example.com/home, they will be redirected to https://example.com automatically.

Please note that you might need to clear your Magento cache for the changes to take effect:

php bin/magento cache:clean
php bin/magento cache:flush

With this URL Rewrite in place, you can avoid having your home page accessible from the arbitrary URL, and only have it accessible from the root URL.

answered Mar 21, 2023 at 12:56
3
  • This does not work. As described in the question, this has been attempted, and results in error Request Path for Specified Store already exists. Commented Mar 21, 2023 at 18:29
  • Are you using Nginx ? If so, you may try the following rule : rewrite ^/home$ https://$http_host permanent; Commented Mar 21, 2023 at 22:54
  • We are using Adobe's Magento Cloud. We don't have access to NginX configuration. Commented Mar 26, 2023 at 23:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.