#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    51
    Rep Power
    47

    Help with url rewrite regex


    Hi,

    I have the following url rewrite:

    ^user/([a-z-]+)-([a-z-]+)/$ user.php?name=$1&location=$2

    A sample url would be :

    user/john-doe-south-london/

    The problem is that if name and location are two words and have "-" between them, 3/4 of the string is passed as the first parameter.

    for example if the URL is user/john-doe-south-london/ it will translate to user.php?name=john-doe-south&location=london

    I cannot know how many spaces (dashes) the name or location of a user is. Is there any way I can isolate those two parameters?

    Thanks!
    Last edited by BlazeMike; September 27th, 2017 at 02:11 PM.
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,864
    Rep Power
    9646
    How can you expect a regex to know how many words are in the username or location if you don't even know?

    You need to change your URL pattern.

IMN logo majestic logo threadwatch logo seochat tools logo