January 1, 2014 2:35 pm

How to create SEO Optimized URLs from String in PHP

A uniform resource locator abbreviated URLs or web address used to locate exact information page on the web like https://www.phpgang.com/how-to-create its a URL  and how-to-create is  created from a string and in this tutorial I will give you a method to know about that function of PHP. This is a very basic solution for beginner PHP Developers and programmers.


Here is the code snippet to create URLs from a String.


To use this function you have to create this page index.php which contain function call line with parameters.

This function first of all convert string to utf-8 after that use perg_replace and change white spaces to “-” and remove special characters.

These URLs also make good impact on your SEO and recommended by Google.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.

Tutorial Categories:
  • Yogi Singh

    ok, but how will it reflect the string to address bar

    • huzoorbux

      @disqus_xCJR1jcNNv:disqus Changes added in article how to use it..

      • Yogi Singh

        ok when i get the string, i can save in db or use as permalink
        but how will it show in address bar in top. i am working on core php no frameworks.
        what changes to be made in htaccess

  • Toreto

    looks good – but how to use it ? By include ?

    • huzoorbux

      Changes added in article how to use it..

  • Thank you. Nice info

  • Lokesh Sharma

    hello Sir give me some ideas about SEO Please

  • Lokesh Sharma

    help Me Sir

  • Shahbaz Ahmed Bhatti

    i need some help in page url can anybody help me. phpGang team i need some help please

    • huzoorbux

      What help you need?

      • Shahbaz Ahmed Bhatti

        Asalamu Alaikaum,
        Dear HuzorBux Sir
        i m new in Web Development. i Found your site very late it is very nice and good for learning. The Help i need is that

        Can PhpGang Team Help me in Page URL a si asked yesterday
        Let sya i have a page url is
        sitenamecom/recird .php?id=12&city=37

        i want like this sitenamecom/record .php

        hope u will understoood

        • huzoorbux

          You can do it with .htaccess.

  • Md Asif

    As Salaam O Aleykum Huzoor Sir. May you please publish an article on building blog with all the facilities. like recent post, categories & archives.