?
Solved

allowing for spaces in a url rewrite

Posted on 2006-11-30
14
Medium Priority
?
209 Views
Last Modified: 2010-03-04
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?
0
Comment
Question by:scm0sml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 18052270
RewriteRule ^results-quick-([\ A-Za-z]+).htm$ searchResults.php?mode=quick&search=$1
0
 

Author Comment

by:scm0sml
ID: 18052310
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
 
LVL 43

Expert Comment

by:ravenpl
ID: 18052339
if You want to use space, put '\ ' a space prefixed by backslash - that's what I did.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:scm0sml
ID: 18052359
ive been given a better solution

[.] allows all chars.....including spaces and digits!! :)
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 18052364
I thought You want not all, but space + A-Z + a-z
0
 

Author Comment

by:scm0sml
ID: 18052459
plus digits..............

in any order...........
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 18052677
And if You using dot, You can '.+' instead of '[.]+'
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 18052683
RewriteRule ^results-quick-([\ 0-9a-z]+).htm$ searchResults.php?mode=quick&search=$1 [NC]
last [NC] means no-case-sensitive
0
 
LVL 16

Accepted Solution

by:
HackneyCab earned 2000 total points
ID: 18059411
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
 

Author Comment

by:scm0sml
ID: 18059486
no im not dont worry.

ive just replaced the space with _ and then vice versa at the other end using php str_replace.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 18093144
Well In fact I answered Your question, hence no points? Whatever...
0
 

Author Comment

by:scm0sml
ID: 18093173
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
 
LVL 43

Expert Comment

by:ravenpl
ID: 18093364
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
 
LVL 16

Expert Comment

by:HackneyCab
ID: 18094037
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question