Welcome to WebmasterWorld Guest from 54.158.51.150

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Space in file name

Can't seem to get it to work in .htaccess

     
3:30 am on Dec 16, 2005 (gmt 0)

5+ Year Member



I have a file on my server - call it filename.html. Google Sitemaps is telling me someone is trying to access it at the URL file%20name.html and this is throwing up an error. (%20 is the space character, yes?) Someone on the web must have linked to the file incorrectly, but I haven't been able to locate it.

I assumed I could fix this in .htaccess, by putting in a redirect but the usual method doesn't seem to work (it tells me the file can't be found):

Redirect Permanent /mydir/file%20name.html [mysite.com...]

I'm assuming the %20 is throwing it off somehow. (Making it an actual space, rather than %20, doesn't work either.)

Does the %20 have to be escaped somehow? Is there a different way to do this?

Many thanks for any suggestions.

4:06 am on Dec 16, 2005 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Try using RedirectMatch -- It will allow you to use regular expressions, and so insert a space by preceding it with the regex 'escape' character "\".

RedirectMatch 301 ^/mydir/fi[b]le\ na[/b]me.html$ http://example.com/mydir/filename.html

If that doesn't work, you can definitely use mod_rewrite to handle this problem -- It comes up fairly often in this forum.

Jim

4:44 am on Dec 16, 2005 (gmt 0)

5+ Year Member



Thanks - I just gave that a try, and it it kicked up a 500 server error that made the whole site inaccessible. ModRewrite is way beyond me, so I'll probably just have to let the error sit there.
1:12 am on Dec 18, 2005 (gmt 0)

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You ~REALLY~ do not want to be using spaces in file names. Stick to underscores or dashes to be safe.
2:54 am on Dec 18, 2005 (gmt 0)

10+ Year Member



"You ~REALLY~ do not want to be using spaces in file names. Stick to underscores or dashes to be safe."

He's not. Someone else is linking to him incorrectly, or directly entering it in the address bar. At least that's what he said in his post (The first one above ^^).

F

3:10 am on Dec 18, 2005 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



> it kicked up a 500 server error that made the whole site inaccessible.

Most 500-Server Errors do... :)

So what was in your server error log file when you got that 500 response? -- It'll often tell you exactly what's wrong if it is a server-level error.

If you want to try mod_rewrite and your server setup allows it, I know this works because I'm using it:


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^\ ]*)\ (.*)$ http://www.example.com/$1$2 [R=301,L]

Jim
 

Featured Threads

Hot Threads This Week

Hot Threads This Month