Guys, Im trying to redirect from: w ww.domain.com/data%20sheets/sheet_1.pdf to w ww.domain.com/sheet_1.htm But it wont work. I am thinking its because the pdf file i am trying to redirect from is in a folder whose name has spaces, on the server it just appears as data sheets but in the web browser when you view the file it shows the address line as http://www.domain.com/data sheets/sheet_1.pdf What should I put in my rewrite to get this to work, its driving me mad. Thanks,
The %20 is standard URL notation for a space. The percent (%) is a delimiter indicating the next two characters represent the decimal value of an ascii character. Your rewrite should include that anywhere a space appears in the rule. The purpose is to avoid conflicts with characters that are meaningful to browsers. When a space is encountered in a URL that indicates the end of the URL. In order to prevent the browser from stopping at a space you must "fool" it into continuing. That is done buy changing the space to %20 which the server knows how to interpret. Any ascii character can be included in a URL in this manner.
Hi, Thanks for the full explanation. I understand that the %20 is the notation for a space, but my rewrite rule above will just not work and the pdf file keeps loading instead of redirecting to the .htm file. I just thought it wasnt working (and still do) because of the folder name which has a space in it and this was cocking up my rewrite rule. How should I write this rule so it will work. I have tried a 301 from a another htm to another htm not inside this folder and it works fine Thanks in anticipation Steve
Sorry, I guess I misread what you are trying to do. I don't think I still understand. If I take what you are saying literally, it sounds like you are trying to do a redirect from a pdf file. That is not possible since it is the pdf reader that is displaying the file not a browser. I am not aware of a pdf reader that understands html meta-tags, which is what is needed to tell a browser to do a redirect. I didn't really think that is what you wanted, thus my misunderstanding. Perhaps you could expand and clarify a little more. P.S. Can I also assume the space in the "w ww" is a typo? That won't work in any case.
Yes, I want a collection of PDF files that are in googles index to redirect to their newly created .htm file. So you cannot redirect a pdf is what I seem to be learning? The space in the www was added to avoid auto link create by DP, as this then made it impossible to see the underscore Thank, appreciate your help. Steve
All I have done is added the bottom 2 lines, to the existing htaccess file. The person above is saying you cant redirect a pdf!? I dont understand that because it wouldnt get that far, its a server side response to an address. Anyway, hopefully you can help by looking at the below.Thank you. # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName xxxx.co.uk AuthUserFile /homepages/33/d112078959/htdocs/_vti_pvt/service.pwd AuthGroupFile /homepages/33/d112078959/htdocs/_vti_pvt/service.grp RewriteEngine on RewriteRule ^xxxx%20xxxx%20xxxx/xxxx_xxxx.pdf /xxxx_xxxx.htm [R=301,L]
RewriteRule ^xxxx\ xxxx\ xxxx/xxxx_xxxx\.pdf$ http://www.domain.com/xxxx_xxxx.htm [R=301,L] for one URL, or RewriteRule ^data\ sheets/([^.]+)\.pdf$ http://www.domain.com/$1.htm [R=301,L] for a whole directory, might do it.