Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Halim's avatar
Level 2

htaccess for Lumen Api not working

Im doing an api with Lumen, Im trying to remove the public folder from the url, (Im sure I will do that when I host the Api somewhere)

I do htaccess on the root something like: (I did many many htaccess by the way, lot of try)

RewriteEngine On
RewriteRule ^(.*)$ public/ [L]

1- I tried my endpoints:

http://localhost/store/
http://localhost/store/api/v1/users

I always get: NotFoundHttpException

2- but when I do:

http://localhost/store/public/
http://localhost/store/public/api/v1/users

I get the response with no problem

3- or when I use the:

php -S localhost:8000 -t public
http://localhost:8000/api/v1/users

also works

0 likes
2 replies
GamerFac3's avatar

Why do you even want to rewrite this with a htaccess file? You're not in control of renaming your routes?

Halim's avatar
Level 2

@gamerfac3, I did search online and most of them suggest htaccess, what do you suggest

Please or to participate in this conversation.