我已添加以下.htaccess文件
RewriteEngine On
RewriteBase /site/public/admin/
RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+) [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2 [L,NC,QSA]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L]
# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
添加上面的代码后,我的表单提交按钮停止工作。 HTML表单标签位于
之下<form role="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" id="rta_parties_form">
<?php require_once 'php_include/parties/form_parties.php';?>
</form>
我也尝试了以下内容,但也没有效果。
RewriteCond %{REQUEST_METHOD} !POST
模式重写不太好
任何想法?
答案 0 :(得分:1)
在RewriteBase
行之后插入此规则,以跳过POST
次请求的重写规则:
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]
答案 1 :(得分:1)
您可以在.htaccess文件中尝试以下操作
RewriteCond %{REQUEST_METHOD} !POST [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
您可以使用link获取完整答案