<p>I solved the issue by adding custom routes to our Craft CMS install instead of using the .htaccess. Actually a better solution since we do not need .htaccess</p>

CC BY-SA 4.0
2023-08-02T14:59:06.027Z
2023-08-02T14:59:06.027Z
Kenneth
<p>Currently we have a route called <code>/products</code>. On this route there is a SPA active which handles the routes after <code>/products</code>. To ensure that people don't get a 404 when directly typing in a route like <code>/products/product-01</code> (because that page officially doesn't exist in Craft). We've setup a redirect (.htaccess) from <code>/products/.*</code> back to <code>/products</code> where the application handles the routing.</p>
<p>In Craft this seem to not work and give a 404. In case we make the base url <code>/en/products</code> a level deeper, there is no issue. So for example <code>www.domain.com/en/products/products-01</code> doesn't give this issue while <code>www.domain.com/products/products-01</code> does.</p>
<p>Anyone have any experience with this?</p>

CC BY-SA 4.0
2023-08-01T13:16:24.033Z
Sounds like your redirect rule might just be incorrect. Can you post the `.htaccess` rule? Also, what's the base URL of your site in the settings? Is `en` the primary site?
MoritzLost
CC BY-SA 4.0
2023-08-02T06:34:15.460Z
@MoritzLost see below

```RewriteRule ^products/.* /products [L]```
Kenneth
<redirect><routing>
Redirect from /products/.* to /products not working
# Redirect from /products/.* to /products not working

(Asked by: username_0 on 2023-08-01)

Currently we have a route called `/products`. On this route there is a SPA active which handles the routes after `/products`. To ensure that people don't get a 404 when directly typing in a route like `/products/product-01` (because that page officially doesn't exist in Craft). We've setup a redirect (.htaccess) from `/products/.*` back to `/products` where the application handles the routing.

In Craft this seem to not work and give a 404. In case we make the base url `/en/products` a level deeper, there is no issue. So for example `www.domain.com/en/products/products-01` doesn't give this issue while `www.domain.com/products/products-01` does.

Anyone have any experience with this?

**Tags:** redirect, routing
> **Comments:**
> **username_1**: Sounds like your redirect rule might just be incorrect. Can you post the `.htaccess` rule? Also, what's the base URL of your site in the settings? Is `en` the primary site?  
> **username_0**: @MoritzLost see below  ```RewriteRule ^products/.* /products [L]```  

---

## 1 answers

### Answer by username_0 on 2023-08-02. Score: 1

I solved the issue by adding custom routes to our Craft CMS install instead of using the .htaccess. Actually a better solution since we do not need .htaccess


---

