Question

example link upload.php?id=46. I want to disallow all the link ie id=1,2,3 How can I do that using a special character

will this work for me?

disallow:/upload.php?id=*
Was it helpful?

Solution

Your example will work fine for major search engines, but the final * is unnecessary, and will cause the line to be ignored by older robots that don't support wildcards. The Disallow directive basically means "block anything that starts with the following". Putting a wildcard at the end is redundant, and has no effect on what will be matched. Wildcards are not part of the original robots.txt specification, so not all robots support them. All of the major search engines do, but many older robots do not. The following does exactly the same thing as your example, but without wildcards:

User-agent: *
Disallow: /upload.php?id=

OTHER TIPS

Why not just use a header in the upload.php file? I.e. put:

header("X-Robots-Tag: noindex, nofollow", true);

At the top of upload.php. If you're using Apache to serve your files, you can also set up rule based headers in your configuration file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top