.htaccess url重写-删除.添加尾部斜杠-并缩短查询字符串


.htaccess url rewrite - remove .add trailing slash - and shorten query strings

我最近一直在开发CMS,想删除.php添加尾部斜杠并删除查询字符串,例如page.php?page=联系人到页面/联系人

到目前为止,我的.htaccess文件如下:

# This is a .htaccess file
# Don't edit it.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET' /[^?'s]+'.php'?page=([^&'s]+)&?
RewriteRule (.*)'.php$ /$1/%1/? [L,R=301]
RewriteRule ^([^/]+)/([^/]+)/$ $1.php?page=$2 [QSA,L]

除此之外,我不知道如何缩短查询字符串。我环顾四周,找不到任何其他具体的问题。。。

提前谢谢。

我误解你了。我认为您只需要截断查询字符串。这将从查询字符串中提取page参数值,并将其附加到URL中。?像以前一样截断查询字符串。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET' /[^?'s]+'.php'?page=([^&'s]+)&?
RewriteRule (.*)'.php$ /$1/%1/? [L,R=301]
RewriteRule ^([^/]+)/([^/]+)/$ $1.php?page=$2 [QSA,L]