且构网

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

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

更新时间:2023-02-21 19:34: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 /