Apache 301 redirect - file names with spaces

Discussion in 'General' started by hairydog2, Jan 7, 2007.

  1. hairydog2

    hairydog2 New Member

    I've taken over a website that has been maintained by someone who didn't know what he was doing.

    Most of the old pages had file names such as "Ticket Order Form (Day Tickets).htm"

    I want to point people who come looking for the old pages to the new, properly named pages.

    I've been trying to do it using an apache rewrite command in the .htaccess file in the web directory. The problem is that it won't work with any files that have spaces in the old names (that's nearly all of them)

    Redirect 301 /Ticket%20Order%20Form%20%20(Day%20Tickets).htm http://www.domainname.co.uk/booking_form.html
    gets me a 404 file not found error
    Redirect 301 /Ticket Order Form (Day Tickets).htm http://www.domainname.co.uk/booking_form.html
    gets me (as expected) a 500 server error.

    It works fine for Redirect 301 /default.htm http://www.domainname.co.uk/index.html

    Debian 3.1 perfect build, ISPConfig 2.2.9

    Any suggestions?
     
  2. jnsc

    jnsc rotaredoM Moderator

    I don't know if this works, but did you try to put the name of the page in qoutes like this
    Code:
    Redirect 301 "/Ticket Order Form (Day Tickets).htm" http://www.domainname.co.uk/booking_form.html 
    Another thing you could do is having a look at your log files, in order to see how your apache deals with tis files.

    Or you could use RedirectMatch instead of Redirect http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirectmatch
     
  3. hairydog2

    hairydog2 New Member

    That sorted it! Both of your suggestions worked. Thanks.

    Now I all I have to work out is why I spend so long struggling with it before asking here.
     

Share This Page