使用.htaccess将具有查询字符串的URL重定向到404页面

问题描述:

I want to redirect "http://www.example.com/?ac=2&slt=8&slr=1&lpt=1" this url to 404 page through .htaccess. Please provide solution.
Thanks

Add this rule to your document root's htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^ac=2&slt=8&slr=1&lpt=1$ 
RewriteRule ^/?$ - [L,R=404]

Detail document for modrewrite and htaccess :

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

You can generate custom htaccess file with:

http://www.htaccessredirect.net/