SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    detecting repeating hyphens in url rewrite

    Hello everyone.

    I have a website that has a changing url to be rewritten according to the name of the product or a navigation name.

    I have to distinguish between navigation names and product names that have to be redirected to two diffrent pages.

    Lets say that one of my navigations is 'Beautiful flowers'. Then that would be redirected as www.exp.com/beautiful-flowers/ to navigation.php.
    But i also have product names that has to be distinguished like that but they can change beacuse the customer gives names to products with cms.
    It could be 'Red Rose' or 'Beautiful Desert Red Rose' or just 'Rose' and that product has to be redirected to products.php.

    I guess my question is, what would be the pattern that would search a string with unknown number of hyphens?

    Thank you in advance

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,268
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by good_boy View Post
    Lets say that one of my navigations is 'Beautiful flowers'. Then that would be redirected as www.exp.com/beautiful-flowers/ to navigation.php.
    But i also have product names that has to be distinguished like that but they can change beacuse the customer gives names to products with cms.
    It could be 'Red Rose' or 'Beautiful Desert Red Rose' or just 'Rose' and that product has to be redirected to products.php.
    So, to clarify, are you saying that navigation names and product names are both represented the same way? That is,

    exp.com/navigation-name/

    exp.com/product-name/
    "First make it work. Then make it better."

  3. #3
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeff Mott View Post
    So, to clarify, are you saying that navigation names and product names are both represented the same way? That is,

    exp.com/navigation-name/

    exp.com/product-name/
    yes, but the product name can vary with the number of word it can hold but the navigation names are constants. I made
    a temp solution with (nav-name1|nav-name2| etc... but thats awful. i know theres a better solution.

  4. #4
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,268
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by good_boy View Post
    I made
    a temp solution with (nav-name1|nav-name2| etc... but thats awful. i know theres a better solution.
    There might not be. What you have here is essentially a namespace clash.

    It sounds like you have a fixed number of constant navigation names, and an indefinite number of variable product names. Given that, I would resolve this namespace clash by deciding that navigation names take precedence. Check for the known navigation names first, and rewrite to navigation.php as appropriate. Or if none of the navigation names matched, then assume it's a product name and rewrite to products.php.
    "First make it work. Then make it better."

  5. #5
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have done that already but i thought there is a better solution.

    Many thanks for the info


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •