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

I want to redirect only one specific URl (ex. mypage.com/1234/page/) to error page 404. How to achieve it in htaccess?

share|improve this question
up vote 3 down vote accepted

With mod_alias activated, you can do that with the Redirect directive:

Redirect 404 /1234/page/ 

Redirect expects usually the target as 3rd argument, leaving it brings up the configured ErrorDocument. If a target is added it would result in an internal error.

As can be read in the docs:

If the status is between 300 and 399, the URL argument must be present, otherwise it must be omitted.

(Thanks @w3d for that note!)

share|improve this answer
If you specify a status code other than 3xx in the Redirect directive (ie. 404 in this case) - in which case it's not actually a redirect - then the destination URL (3rd argument) should be omitted. Whatever is specified as the appropriate ErrorDocument will then be served instead. Specifying the 3rd arg in this instance will actually result in a 500 internal server error. – w3dk Jan 29 '13 at 9:38
Thanks @w3d for spotting that. Answer updated. I usually use Redirect just for ...redirects and thought it would be a nice oneliner for that task. – initall Jan 29 '13 at 9:49

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.