Forum Moderators: phranque
eg
These are fine, and should be allowed
www.example.com/shop/?ProductID=variable
www.example.com/shop/
www.example.com/
Don't want random queries from google yahoo returning 200 ok
eg from log files google wants
www.example.com/shop/?A=756&B=56
www.example.com/CFID=65850&CFTOKEN=8789
or any other thing yahoo or google hits the site with.
I can match any query string with
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^(.*) http:// www.example.com/pita.php
#pita.php doesnt exist so server returns 404 error
but the above would also catch www.example.com/shop/?ProductID=variable
Trying to do...
if not /?ProductID=foo or / then 404
Using
Apache/1.3.27
.htaccess in root folder.
Other rewrite rules already in htaccess
RewriteEngine On
###
#Redirect "/index.html php" or "/foo/.../index.html php" to "/" or "/foo/.../"
#This also works for "index.php?ProductID=foo" to "/?ProductID=foo"
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]*\index\.(php¦html)[^\ ]*\ HTTP/
RewriteRule ^(.*)index\.(php¦html)$ http:// www.example.com/$1 [R=301,L]
I need sleep.
Trying to do...
if not /?ProductID=foo or / then 404
# Force 404 response if query is non-blank and contains non-ProductID parameters
# IF query is non-blank
RewriteCond %{QUERY_STRING} .
# AND IF query is NOT "ProductID=<letters, numbers, or hyphen>"
RewriteCond %{QUERY_STRING} !^ProductID=[A-Za-z0-9\-]*$
# THEN rewrite to non-existent file to force a 404
RewriteRule .* /path_that_does_not_exist [L]
# Force 404 if non-blank query contains non-ProductID query
# IF query is non-blank
RewriteCond %{QUERY_STRING} .
# AND IF query is NOT "ProductID=<letters, numbers, or hyphen>"
RewriteCond %{QUERY_STRING} !^ProductID=[A-Za-z0-9\-]*$
# THEN force a 410-Gone response
RewriteRule .* - [G]