homepage Welcome to WebmasterWorld Guest from 50.19.169.37
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Space in file name
Can't seem to get it to work in .htaccess
anax




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

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.

 

jdMorgan




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

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

anax




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

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.

JAB Creations




msg:1510051
 1:12 am on Dec 18, 2005 (gmt 0)

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

buy_online




msg:1510052
 2:54 am on Dec 18, 2005 (gmt 0)

"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

jdMorgan




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

> 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved