Results 1 to 4 of 4
  1. #1
    Full Member
    Join Date
    October 22nd, 2006
    help with urlencoded product names
    I written a php script that creates and saves an HTML page. To make it SEO friendly I decided to use the urlencoded product name as the filename. So the relevant part of my script is:


    Everything works well except for brackets.

    A product "American Crew Moisturising Shampoo (250ml)" when urlencoded produces :"American+Crew+Moisturising+Shampoo+%28250ml%29.htm" however when I click the link I get the error "/American+Crew+Moisturising+Shampoo+(250ml).htm was not found on this server."

    It's no problem to correct for the brackets but does anyone know if other characters are affected in this way?

  2. #2
    Join Date
    January 18th, 2005
    It would depend on the server OS and web server, I think - but the safest practice (and most portable) is to remove ALL non-alphanumeric characters except hyphens (replacing the other characters with hyphens and merging multiple hyphens into one).

  3. #3
    ABW Ambassador Daniel M. Clark's Avatar
    Join Date
    January 7th, 2006
    Houston, TX
    Agreed - I would remove all non-alpha-numerics from the title. Spaces, braces, parentheses, ampersands, number signs... all kinds of things can mess up a url.
    Daniel M. Clark
    Tech Manager
    Greg Hoffman Consulting

  4. #4
    Full Member
    Join Date
    October 22nd, 2006
    Thanks for your suggestions Mark and Hectic here is the code I have come up with:

    PHP Code:
    $product_name=ereg_replace("[^0-9a-zA-Z \.]" ,"-",$product_name);
    First get rid of the html entities or you get things like "-amp-" in the url. Next replace any characters you don't want with "-", remove duplicate "-" and finally remove the "-" if it is the first or last character.

    I'm sure it's not the perfect solution but it works for now.

    Regards Bob

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Funny Product Names
    By Rhea in forum Virtual Family and Off-Topic
    Replies: 1
    Last Post: October 11th, 2008, 01:38 PM
  2. Gender specific naming conventions in product names
    By Chuck Hamrick in forum Voting Booth
    Replies: 4
    Last Post: March 28th, 2006, 11:45 AM
  3. How to make product page names in index
    By mreider in forum WebMerge (
    Replies: 2
    Last Post: April 15th, 2005, 08:49 PM

Posting Permissions

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