Метод PHP = «post» перестал работать после того, как я добавил этот .htaccess… Почему?
Я добавил этот .htaccess, чтобы удалить расширение файла из URL, поэтому вместо «index.php» будет отображаться только «index». Но после того, как я это сделал, мой<form method="post">
перестал работать
Options +FollowSymLinks -MultiViews
Options +Indexes
AcceptPathInfo Off
RewriteEngine on
RewriteBase /
#Force from http to https
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^mysite.com$
RewriteRule ^(.*)$ https://mysite.com/$1 [R=301]
#take off index.html
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . http://www.%{HTTP_HOST}%1 [R=301,NE,L]
## 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]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
## hide .html extension
# To externally redirect /dir/foo.html to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [L]
Вот пример:
/* Worked before .htaccess, but not anymore */
<form method="post" action="pwreset.php" class="form-stacked">
/* Removing .php from action works. But there are hundreds of files and this method is not very trustworthy */
<form method="post" action="pwreset" class="form-stacked">
PS: если я использую обычные правила .htaccess, как этот:
RewriteRule ^ index $ ./index.php [L, NC]
Он не будет скрывать .php во всех случаях