Showing results for 
Search instead for 
Did you mean: 

404 Error in Multistore Setup with Subdirectories

404 Error in Multistore Setup with Subdirectories



I am currently facing an issue while setting up a multistore in Magento using subdirectories. My setup involves creating separate store views for different languages, and I'm trying to set each one up in its own subdirectory. I've followed various guides and tried different approaches, but I'm still encountering 404 errors whenever I try to access the store views via their subdirectories.


Here's what I have done so far:


  1. I've created the necessary websites, stores, and store views in Magento's backend. For example, I've created a store view with the code 'bg' for the Bulgarian language.
  2. I've copied the index.php and .htaccess files from the Magento root into my subdirectory (/bg).
  3. I've made the necessary modifications to the index.php file in my subdirectory to specify the run code and run type.

    index.php in the subdir:


    require realpath(__DIR__) . '/../app/bootstrap.php';
    $params = $_SERVER;
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'bg'; 
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; // store or website
    $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
    $app = $bootstrap->createApplication('Magento\Framework\App\Http');

    .htaccess in the subdir:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/pub/
    RewriteCond %{REQUEST_URI} !^/setup/
    RewriteCond %{REQUEST_URI} !^/update/
    RewriteCond %{REQUEST_URI} !^/dev/
    RewriteRule .* /pub/$0 [L]
    DirectoryIndex index.php
  4. I've ensured that the subdirectory, the copied index.php, and .htaccess files have correct permissions on the server.
  5. I've checked and double-checked the base URLs for each store view in the Magento backend to ensure they're pointing to the correct subdirectories.
  6. I've tried creating symlinks for the Magento folders (app/, errors/, ...) in the subdirectory.
  7. I've flushed Magento's cache several times during this process.

Despite doing all this, I'm still encountering 404 errors. I've checked my server's error logs, but I can't find anything that would point to the cause of these errors. I'm running on a cPanel & WHM setup and as far as I can tell, there are no server-side issues causing this.


Has anyone encountered this issue before? Could there be something I've missed, or is there something specific to my setup that's causing this issue? Any guidance would be greatly appreciated.

The system is Almalinux 8.8 with cPanel/WHM/Apache 2.4


Thank you.


Re: 404 Error in Multistore Setup with Subdirectories

Hello @GEORGITTAN991f 


As I can understand your requirement you just need multi language setup for your site with language switcher option and the URL have the store code of your store.


to archive above requirement you need to follow below configurations. 


If you need more information then let me know.


If my answer is helpful full then please set the accept solution flag and kudos flag so other members can take the same reference.