14

I have a link from anther website that I do not have control of http://example.com/one two three.exe

The correct URL is http://example.com/one_two_three.exe

Note the underscores instead of spaces.

I searched the internet and found this code snippet for .htaccess

# Redirect old file path to new file path Redirect /one%20two%20three.exe http://example.com/one_two_three.exe 

I added this snippet to my preexisting root .htaccess at the top of the file.
But it does not seem to work. My browser does not redirect and I get a 404 error page.

I believe that it has something to do with the spaces in the original URL but I don't know how to handle spaces in the URL.

Suggestions?

1 Answer 1

36

You could try a couple of things (both untested)

Redirect "/one two three.exe" http://example.com/one_two_three.exe 

or use RewriteRule instead of Redirect:

RewriteRule /one\ two\ three.exe http://example.com/one_two_three.exe 
Sign up to request clarification or add additional context in comments.

1 Comment

Second one worked for me. I needed to redirect to an URL with a space in it "\ " works perfect!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.