首页 > 解决方案 > PHP .htaccess 重写 url

问题描述

我在下面写了 URL 重写规则,但它也删除了 post 参数。请帮我用原始参数重写 URL

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

标签: phpapache.htaccessphp-7.2

解决方案


使用 flag R=301,您正在执行重定向,而不是仅在内部重写 URL。删除它,一切都应该正常


推荐阅读