PHP method=“post” stopped working after I added this .htaccess… Why?

后端 未结 2 718
孤独总比滥情好
孤独总比滥情好 2020-12-04 01:46

I\'ve added this .htaccess to remove file extension from the URL, so instead \"index.php\", it would show \"index\" only, all the times. But after I did it, my

2条回答
  •  萌比男神i
    2020-12-04 02:39

    This is happening because you are redirecting here:

    ## hide .php extension
    # To externally redirect /dir/foo.php to /dir/foo
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
    RewriteRule ^ %1 [R,L,NC]
    

    When you redirect, the request BODY doesn't always get included, you can try adding an exception for POST:

    ## hide .php extension
    # To externally redirect /dir/foo.php to /dir/foo
    RewriteCond %{REQUEST_METHOD} !POST [NC]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
    RewriteRule ^ %1 [R,L,NC]
    

提交回复
热议问题