Forum Moderators: phranque

Message Too Old, No Replies

301 redirects not working

Problem with files & folders with spaces in name

         

Mokita

3:14 am on Oct 10, 2006 (gmt 0)

10+ Year Member



I need help please - I have tried everything I know, but can't get it to work.

Background is: I have redesigned an ancient FrontPage site that had nightmarish Windows-type URLs containing spaces and capital letters. So virtually every page has been renamed.

The simple names are redirecting fine e.g.

Redirect 301 /Old_Page.htm http://www.example.com/newpage.html

However this is not, it throws a 404:

Redirect 301 /Contact\%20Us.htm http://www.example.com/contact-us.html

I have also tried this:

Redirect 301 /Contact\ Us.htm http://www.example.com/contact-us.html

but that produces a 500 server error.

Even worse, there were extensive directories that looked like this:

/Folder One/Keyword1 keyword2 keyword3/

I tried to get around the directory problem, by recreating the orginal directory path and placing an .htaccess file in the final folder, so as to avoid the space problem altogether. Luckily only one file has a space in its name.

However, not even the .htaccess placed in the recreated Old directories is working. Any request for one of the old files gets a 404.

I tried recreating one page, and putting the PHP redirect code on it - and joy of joys it works! However, that means I would have to recreate about 200 files, which I'd rather not do.

Does anyone have any suggestions as to how I can get straight 301 redirects to function as intended?

N.B. In case it matters, the server I am hosting the new site on just had a massive security upgrade. I'm not sure if this is relevant, but it did affect one PHP script I am using.

Romeo

9:49 am on Oct 10, 2006 (gmt 0)

10+ Year Member



Hi Mokita,

Have you tried putting quotes around the filename:
Redirect 301 "/Contact Us.htm" http://www.example.com/contact-us.html

Kind regards,
R.

Mokita

1:17 pm on Oct 10, 2006 (gmt 0)

10+ Year Member



Have you tried putting quotes around the filename:
Redirect 301 "/Contact Us.htm" http://www.example.com/contact-us.html

No, I hadn't, but unfortunately I tried it and it didn't work.

Does anyone have any suggestions for a suitable mod_rewrite?

I have tried several attempts at mod_rewrite, but failed miserably.

I need to rewrite this:

/Oldfolder/Keyword1 keyword2 keyword3/variousfiles.htm

to

/newfolder/

such that the .htaccess in /newfolder/ will redirect the old file names to the new ones (via 301 redirects in .htaccess file located in /newfolder/)

[edited by: Mokita at 1:17 pm (utc) on Oct. 10, 2006]