diff --git a/App/Request/PathInfoProcessor.php b/App/Request/PathInfoProcessor.php
new file mode 100644
index 0000000..4af1aca
--- /dev/null
+++ b/App/Request/PathInfoProcessor.php
@@ -0,0 +1,48 @@
+storePathInfoValidator->getValidStoreCode($request, $pathInfo);
+ if (!empty($storeCode)) {
+ try {
+ $path = $this->pathResolver->resolve($this->storeRepository->getActiveStoreByCode($storeCode));
+ } catch (LocalizedException) {
+ return $pathInfo;
+ }
+ if (!$request->isDirectAccessFrontendName($path)) {
+ $pathInfo = substr($pathInfo, strlen($path) + (int)str_starts_with($pathInfo, '/')) ?: '/';
+ } else {
+ //no route in case we're trying to access a store that has the same code as a direct access
+ $request->setActionName(Base::NO_ROUTE);
+ }
+ }
+
+ return $pathInfo;
+ }
+}
diff --git a/Plugin/App/Request/PathInfo.php b/Plugin/App/Request/PathInfo.php
deleted file mode 100644
index 7867313..0000000
--- a/Plugin/App/Request/PathInfo.php
+++ /dev/null
@@ -1,30 +0,0 @@
-config->isEnabled()) {
- $requestUri = $this->storePathFixer->fix($baseUrl ? $requestUri : $this->request->getUriString(), $requestUri);
- }
-
- return [$requestUri, $baseUrl];
- }
-}
diff --git a/Plugin/App/Request/StorePathInfoValidator.php b/Plugin/App/Request/StorePathInfoValidator.php
new file mode 100644
index 0000000..3779c32
--- /dev/null
+++ b/Plugin/App/Request/StorePathInfoValidator.php
@@ -0,0 +1,36 @@
+config->isEnabled()) {
+ $uri = $request->getUriString();
+ /** @var Store $store */
+ foreach ($this->storeRepository->getList() as $store) {
+ if ($store->getId() && str_starts_with($uri, $store->getBaseUrl())) {
+ $pathInfo = $store->getCode();
+ }
+ }
+ }
+
+ return [$request, $pathInfo];
+ }
+}
diff --git a/Service/StorePathFixer.php b/Service/StorePathFixer.php
deleted file mode 100644
index fa19757..0000000
--- a/Service/StorePathFixer.php
+++ /dev/null
@@ -1,35 +0,0 @@
-storeRepository->getList() as $store) {
- if ($store->getId() && str_starts_with($baseUrl, $store->getBaseUrl())) {
- return $this->uriUtils->replacePathCode($requestUri, $store);
- }
- }
-
- return $requestUri;
- }
-}
diff --git a/etc/di.xml b/etc/di.xml
index a0a91a3..743d26d 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -15,10 +15,15 @@
+
+
+ Opengento\StorePathUrl\App\Request\PathInfoProcessor
+
+
-
-
+
+