且构网

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

使用.htaccess从URL末尾删除查询字符串

更新时间:2023-02-21 19:42:57

很简单,只需使用:

RewriteCond %{QUERY_STRING}    "post_type=" [NC]
RewriteRule (.*)  /$1? [R=301,L]

如果要将其添加到wordpress网站,则需要在任何wordpress规则之前添加它:

If you are going add this to wordpress website, you need add it before any wordpress rules:

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

但在

RewriteBase /