Try it like this and see if it works its not tested yet please give it a try
etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Store\Model\Store">
<plugin name="vendor_hide_default_store_code" type="\Vendor\HideDefaultStoreCode\Plugin\Model\HideDefaultStoreCode" sortOrder="0" />
</type>
</config>
HideDefaultStoreCode
<?php
namespace Vendor\HideDefaultStoreCode\Plugin\Model;
class HideDefaultStoreCode
{
/**
*
* @var \Vendor\HideDefaultStoreCode\Helper\Data
*/
protected $helper;
/**
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
*
* @param \Vendor\HideDefaultStoreCode\Helper\Data $helper
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
*/
public function __construct(
\Vendor\HideDefaultStoreCode\Helper\Data $helper,
\Magento\Store\Model\StoreManagerInterface $storeManager
){
$this->helper = $helper;
$this->storeManager = $storeManager;
}
/**
*
* @param \Magento\Store\Model\Store $subject
* @param string $url
* @return string
*/
public function afterGetBaseUrl(\Magento\Store\Model\Store $subject, $url)
{
$url = str_replace('/'.$this->storeManager->getDefaultStoreView()->getCode().'/','/', $url);
return $url;
}
}