Handling Magento Store Views as Subpaths for Geo-Targeting
In today’s competitive e-commerce landscape, effective SEO strategies are crucial for driving organic traffic to your online store. One such strategy recommended by many SEO specialists is the use of subfolders for language-specific or geo-targeted content.
If you’re looking to add a specific version of your Magento installation in a /aus/ subfolder for Australian targeting purposes without creating a separate language, this guide will walk you through the process step-by-step from a developer’s perspective.
Understanding the Requirements
To achieve this setup:
- You want to replicate your current store with the same catalog and settings.
- The URL structure should be
www.mystore.com/aus/for the replicated content. - All links within the
/aus/subfolder should point to the correct location.
Let’s dive into how you can accomplish this without requiring a separate installation or language setting in Magento.
Configuring Your Magento Store View
First, we need to create a new store view and assign it to the existing website:
- Navigate to the Admin panel > Stores > Settings > All Stores.
- Click on “Add New Store.”
- In the “Website” dropdown, select your existing website (e.g., “Main Website”).
- Set the “Store” field as a copy of your current store view (e.g., “English”).
- Set the “Store View Code” to “aus.”
- Click on “Save Store.”
Now that you have created the new “aus” store view, let’s proceed with configuring the URL:
- Go to Admin panel > Stores > Configuration.
- Under the “General” section, find the “Web” options and expand it.
Configuring the Subfolder URL in Magento
For each of these settings, make sure to select the scope as “aus”:
- Base URL: Set this to
https://www.mystore.com/aus/ - Secure Base URL: Ensure it matches the “Base URL” (HTTPS version)
- Unsecure Base URL: Match the “Base URL” for HTTP
After updating these settings:
- Click on the “Save Config” button.
- Run
flush:cachecommand from your Magento terminal to clear the cache.
Creating a Redirect in .htaccess
To ensure that any requests without the /aus/ subfolder are redirected to the main store, you can add the following line to your .htaccess file:
RewriteCond %{REQUEST_URI} !^/aus/.*
RewriteRule ^(.*)$ /aus/$1 [L,R=301]
This rule checks if the requested URI does not start with /aus/ and redirects it permanently (status 301) to the same path under the /aus/ subfolder.
Conclusion
By following these steps, you can effectively add a new store view with a specific subfolder URL structure for geo-targeting purposes without creating a separate language in Magento. This approach allows you to maintain a single copy of your catalog while targeting different regions or audiences within the same installation.
Remember to test your configuration thoroughly after making changes and ensure that all links within the /aus/ subfolder are functioning correctly. Proper redirection will help preserve your site’s SEO value and avoid duplicate content issues.
If you’re looking for more advanced Magento development solutions, feel free to explore our services at Laravel Company. Our team of experienced developers can assist with custom integrations, performance optimizations, and advanced SEO strategies tailored to your business needs.