View Tutorial Metadata Edit Content Revision History Add to Watchlist Add New Tutorial Return 404 for URLs with parameters

Return 404 for URLs with parameters

It may be useful for SEO: avoid having two pages with different parameters displaying the same (duplicate) content.

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} . [NC]
RewriteRule .* - [r=404,L]

Tested on Apache2. It will cause the server to issue a 404 response only if there is something after the "?" character in the URL. It can also be extended for example if only some of the parameters should trigger the 404 error.

Only plain text supported.

Optional

Required - will be kept private

Optional

 
 

Rating: (0+, 0-) In: Apache