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

trogne's avatar

redirect post request to root, to index.php

Because of CORS, I cannot make to root. So I want the request to switch to index.php.

Currently I can make a post request (with cors middelware), to "myproject.local/index.php". But I'd like to remove the "/index.php".

How do I do that ? In .htaccess ? In nginx config ?

Thanks in advance for providing a working example. I'm very confused with .htaccess and nginx conf file.

0 likes
1 reply
trogne's avatar
trogne
OP
Best Answer
Level 3

This change works ! :

    # location ~ \.php$ { 
    location ~ \.php$|/$ {

Now I can post to "myproject.local", "myproject.local/index.php", ""myproject.local/someroute"

Please or to participate in this conversation.