views:

316

answers:

1

What I want:

To 301 redirect /file_new.pdf to /file new.pdf ( %20 aka space between file and new )

I'm aware that:

However, I'm personally curious as to how one would do this. Here's what I have so far:

Redirect 301 /file_new.pdf http://sitename.com/file\ new.pdf

The conf file parser throws an error when I invoke the configtest:

Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL

Edit: Apparently the mod_rewrite nor Redirect 301 methods are working for me, possibly because for whatever reason they aren't applying because the file actually exists in that location.

<VirtualHost *:80>
DocumentRoot /www/sitename_com
ServerName site.local
Options -MultiViews

RewriteEngine on
Redirect 301 /pdf/file_new.pdf http://site.local/pdf/file%20new.pdf
RewriteRule ^/pdf/file_new.pdf http://site.local/pdf/file\ new.pdf
RewriteLog "/www/rewrite.log"
</VirtualHost>

In rewrite.log, it tries to match the pattern to each respective uri / http request.. I think something is taking control before it even gets to the mod_alias/mod_rewrite stuff.

So to sum it up, it goes directly to file_new.pdf in the browser and doesn't 301. I'm positive that alias and rewrite are enabled. My apache version is 2.2.

+1  A: 

the Redirect is actually part of mod_alias, not mod_rewrite. i'm glad the %20 worked and you can also use quotes to tell apache that the path that includes the space is the URL to redirect to and not two separate items:

Redirect 301 /pdf/file_new.pdf "http://site.local/pdf/file new.pdf"
jnichols959
I'm aware `Redirect` is part of `mod_alias` as I initially tagged it for mod-alias, it actually didn't work for whatever reason, perhaps something in my Virtualhost? I didn't really tinker around too much with the default httpd.conf, this is on a fresh Lenny debian box. I'll try your method and see if it works.
meder