03 12 2021

今天seo同事提出一个问题发现有人在路由后面加?xxxx=xxx这样的参数来请求站点

解决办法需要重写路由跳转到404页面

上代码:

 <IfModule mod_rewrite.c>

Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{QUERY_STRING} ^([A-Za-z0-9]+)=([A-Za-z0-9]+)$
RewriteRule ^(.*)$ 404.html [QSA,PT,L]
</IfModule>

因为apache无法匹配?所以用RewriteCond获取参数匹配然后在跳转到404页面

发表评论