Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 many redirects working but I have one that needs to be redirected and drop the file name.

redirect 301 /path/to/file/default.aspx

When I implement this it tries to redirect but it does not drop the default.aspx from the URL.

Rewrite Rules:

 ## path relative to web root
 RewriteBase /

 ## workaround for HTTP authorization
 ## in CGI environment
 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

 ## always send 404 on missing files in these folders
 RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

 ## never rewrite for existing files, directories and links
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-l

 ## rewrite everything else to index.php
 RewriteRule .* index.php [L]

The only other directives would be in the vhost config and there is not alot there:

DocumentRoot /var/www/
RewriteEngine on
<Directory /var/www/>
AllowOverride All
share|improve this question
That directive shouldn't result in the behaviour you see, are there any other Redirect directives which are relevant? – mgorven Mar 15 '13 at 22:25
Please edit your question when adding additional details instead of using comments. – mgorven Mar 15 '13 at 22:26

The documentation for Redirect says that

Additional path information beyond the matched URL-path will be appended to the target URL.

so your Redirect line is appending the unwanted filename.

Try this instead:

RewriteCond %{REQUEST_URI} ^/path/to/file/default.aspx$
RewriteRule .*
share|improve this answer
Thanks, but unfortunately this did not fix the redirect. It still takes me to the site root. – Jesse Mar 18 '13 at 17:01

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.