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 have a rewrite rule to rewrite www.mysite.com/default.aspx to www.mysite.com.

RewriteRule ^default.aspx$ / [NC,R=301,L]

On that site i have an asp.net server Button. When i click the button it tries to go to postback to default.aspx, but gets 301'd to the root. This prevents the button's click event from triggering.

How can i redirect default.aspx, without breaking my button's event?

share|improve this question
up vote 3 down vote accepted

You can add this condition RewriteCond %{REQUEST_METHOD} ^GET$ just before rewrite rule to redirect only on GET requests:

RewriteRule ^default.aspx$ / [NC,R=301,L]

This will allow to POST to default.aspx .. but then it will not be redirected at all.

Ideally you would need to fix your server side / HTML: look at your <form action"XXX"> -- change action to / instead of default.aspx (P.S. I'm not familiar with ASP.NET much and cannot 100% that this is how .NET really works, but this is the way how you can fix it if it would be PHP, for example). The idea is -- fix the source of the problem -- so the form gets submitted to / in first place.

share|improve this answer

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.