• Welcome to DNForum.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
    If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the oldest global domain name community on the internet and continues to grow every day. There are over 45,000 domainers on DNForum doing everything from buying domains, selling domains, using our free in-house built tools, learning about domains and discussing domains. Take a minute and Register.

Wanted: Service Reg. Expression & Mod_Rewrite

Status
Not open for further replies.

Mr.Domains

DNF Addict
The Originals
Legacy Exclusive Member
Joined
Sep 29, 2004
Messages
1,417
Reaction score
29
Hi,
I am having a basic problem with Regular Expressions and the Mod_Rewrite rule. I need to pattern match the space (" ") character ???

I am trying to rewrite a URL which contains a username variable:

RewriteRule ^([a-zA-Z0-9_.]*)/index.html /index.php?username=$1 [L,NC]

This works fine with usernames like "Dave_439" or "Emma.C", but unfortuantely the site I'm working on also alows users to have spaces in their username, so I also need to match "Dave 439" or "Emma C".

Does anyone know how to include spaces in my Regular Expression?
(Obviously I have tried [a-zA-Z0-9_. ]* which generates errors...)
 
Probably you should use PHP to replace 'spaces' with something else that can be found within their username.
 
Thanks, but I figured it out, you have to escape the space with a backslash:

[a-zA-Z0-9_\.\ ]*
 
Try:

\x20

That represents dec 32 for 'space' in hex.

OK - crossed posts - both should work ;)
 
Status
Not open for further replies.
Back
Top Bottom