George Johnston
George Johnston

Reputation: 32258

ReWrite RegEx, URL having at least one character

I have the following RewriteRule:

RewriteRule ^/people/([A-Za-z0-9\-\_]*)/?$  /people/people_details.cfm?person=$1 [I,L]

...it works great for forwarding my rule, but I want to make sure that the regex only picks it up if it has more than one character. So really, I need to have my regex...

[A-Za-z0-9\-\_]+

...have an additional rule to say that there has to be at least one character. Right now if I go to...

/people/

...it should go to the default document index.cfm, but because of the rule, it still tries to forward to my people_details.cfm

Any help?

Thanks, George

Upvotes: 2

Views: 1450

Answers (2)

Mark Byers
Mark Byers

Reputation: 838666

Your regular expression that you put in your question already ensures that there must be at least one character. The + means "1 or more", as opposed to * which means "zero or more". Just change the * to a +.

Upvotes: 2

Seaux
Seaux

Reputation: 3517

...it should go to the default document index.cfm, but because of the rule, it still tries to forward to my people_details.cfm

Thats because you have the "/" as optional at the end, which is probably not what you wanted.

Upvotes: 0

Related Questions