allowing for spaces in a url rewrite

i have the following rule:
RewriteRule ^results-quick-([A-Za-z]+).htm$ searchResults.php?mode=quick&search=$1

it works fine unless there is a space in the ([A-Za-z]+), so say rockley park for e.g

how can i allow for spaces in there?
scm0smlAsked:
Who is Participating?
 
HackneyCabCommented:
A valid URL should never contain spaces. Characters such as spaces should be urlencoded with escape codes (the ones that begin with a percent-sign and then two hex digits).

If you're handing out URLs with spaces, then you may have other problems to worry about.
0
 
ravenplCommented:
RewriteRule ^results-quick-([\ A-Za-z]+).htm$ searchResults.php?mode=quick&search=$1
0
 
scm0smlAuthor Commented:
so what is this saying?

any number of spaces and chars? as that is what i need. i also need to accomodate numbers incase they enter rockley park 2 for e.g
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ravenplCommented:
if You want to use space, put '\ ' a space prefixed by backslash - that's what I did.
0
 
scm0smlAuthor Commented:
ive been given a better solution

[.] allows all chars.....including spaces and digits!! :)
0
 
ravenplCommented:
I thought You want not all, but space + A-Z + a-z
0
 
scm0smlAuthor Commented:
plus digits..............

in any order...........
0
 
ravenplCommented:
And if You using dot, You can '.+' instead of '[.]+'
0
 
ravenplCommented:
RewriteRule ^results-quick-([\ 0-9a-z]+).htm$ searchResults.php?mode=quick&search=$1 [NC]
last [NC] means no-case-sensitive
0
 
scm0smlAuthor Commented:
no im not dont worry.

ive just replaced the space with _ and then vice versa at the other end using php str_replace.
0
 
ravenplCommented:
Well In fact I answered Your question, hence no points? Whatever...
0
 
scm0smlAuthor Commented:
well i think that hackneycab gave me the right answer in that a url shouldnt contain spaces..................

but im not prepared to argue over a few points...........

if ee agree with you then im happy to split the points if its possible.
0
 
ravenplCommented:
Well, for You knowledge. URL may contain spaces. It's advised that URL have no whitespaces. This way You have easier debuging and better security.
Think first. I don't need those points. Have enought.
0
 
HackneyCabCommented:
ravenpl, URIs (which includes URLs) may not contain whitespace characters.

If you want to check, take a look at the relevant RFCs, RFC1738 (which is now technically obsolete), and at RFC3986 (general definition of URI syntax). Many characters are permitted in the path of a URL, but whitespace is not among those characters.

However, you did try hard to solve the question as scm0sml asked it, so if a points split occurs, I would not think it unreasonable.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.