Welcome to WebmasterWorld Guest from 54.225.32.164

Forum Moderators: Ocean10000 & phranque

Remove spaces in file name and redirect to root

how to fix it

     
5:40 pm on Jul 3, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:June 4, 2002
posts: 1873
votes: 3


I have a file name that looks like this that I wanted to redirect to the root however it's giving 500 error messages.

RewriteRule ^foldername1/foldername2\ kw1\ kw2\.html$
http://www.example.com/oldfoldername2-kw1-kw2-kw3.html [R=301,L]

Can someone tell me what's wrong with the coding?
9:23 pm on July 3, 2018 (gmt 0)

Full Member

Top Contributors Of The Month

joined:Apr 11, 2015
posts: 311
votes: 21


Providing the spaces are correctly backslash escaped (which they look like they are - but it’s tricky to tell for sure when the code isn’t code-formatted) then there doesn’t appear to be a problem with the directive you posted.

Instead of backslash escaping spaces you can also use the whitespace shorthand character class \s instead or simply surround the argument in double quotes.

Check your error log for the specifics of this error.

Aside: Arguably, this directive doesn’t “redirect to the root”.
12:18 am on July 4, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11388
votes: 156


it's giving 500 error messages

check the server error log file for clues

Can someone tell me what's wrong with the coding?

it appears to be okay.
how do you know this is the rule generating the error causing the 500 status code?