Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which one is correct?

User-agent: *
Disallow: index.php


User-agent: *
Disallow: /index.php

inorder to block all pages like index.php?day=7 index.php?day=15 index.php?day=30

share|improve this question
up vote 2 down vote accepted

You can use the following robots.txt file if you wish to block all robots from accessing your pages.

# robots.txt for www.domain.com to block all bots

User-agent: * 
Disallow: /

If you wish to block all all URLs that include a question mark (?) you can use the following format

# robots.txt for www.domain.com to block URL with ? mark

User-agent: *
Disallow: /*?

For more detailed information on how to write robots.txt visit the following link How to Create Robots.txt Files

share|improve this answer

The second one is better form as it clearly marks the index.php as being the in web root and not in some other subdirectory.

share|improve this answer
Isn't the robots.txt used to block directories and not files? – Alexis Wilke Feb 9 '12 at 0:02
It can block both – John Conde Feb 9 '12 at 0:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.