I am redirecting requests to index.php with .htaccess as follows:
RewriteCond %{REQUEST_URI} index\.php
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
It works fine but the problem is forms are not able to POST anymore.
How can I hide index.php from the url while still being able to POST forms.
the 301 redirect (really any redirect) will kill your post variables. Perhaps post to str_replace('index.php', '', $_SERVER['PHP_SELF'])
or even simpler, when posting to self you can post to just ?
which the browser will just interpret as self client side. It will add a ?
to the url. or maybe $_SERVER['REQUEST_URI']
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.