[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

allowing for spaces in a url rewrite

Posted on 2006-11-30
14
Medium Priority
?
210 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

650 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