![](/img/trans.png)
[英]Remove .php and add trailing slash in url using htaccess not loading css
[英].htaccess url rewrite - remove .php - add trailing slash - and shorten query strings
我最近一直在使用CMS,想删除.php并添加斜杠并删除查询字符串,例如page.php?page = contact到page / contact
到目前为止,我的.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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.