且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

htaccess 删除 .php 并保留查询字符串

更新时间:2023-02-18 19:32:08

匹配整个查询字符串并使用反向引用将其附加到新 URL 应该可行.

Matching the entire query string and appending it to your new URL using a back-reference should work.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ $1.php?%1 [NC,L,QSA]