views:

12

answers:

2

Here is my .htaccess:

...
rewriterule file%20name.htm http://mysite.com/new_name.htm#anchor [r=301,nc,ne]
...

It's not redirected, and I believe this is because it's not targeting the file with the %20 in the name. As for the flags, I used ne to not rewrite the #anchor portion of the redirect.

Also, the flag "nu" breaks my file and I get internal server 500 error.

Thanks you.

A: 

Not the best answer, and can only be used in specific cases, but I changed

file%20name.htm

to

file.*

so it will match any filename that starts with "file", regardless of spaces and special chars.

Khan
+1  A: 

When mod_rewrite is invoked, the path has already been decoded as part of Apache's request processing. So, if you want to check for a space, you can do so literally:

RewriteRule file\ name\.html http://example.com/new_name.htm#anchor [R=301,NC,NE,L]

The NU flag doesn't exist, which is why you get an internal server error when you try to use it.

Tim Stone