The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Article title name as URL?

  • # April 17, 2013 at 2:34 am

    I am working on a simple CMS now, i have made post-new-page form, if i click “submit” button, the content will be saved into the database, by the same time i want the PHP script automatically create new folder in my root folder (i’m not sure whether it’s correct to create inside my root folder?)

    This is [the example]( “example”).

    As you can see, the article’s URL (**speed-up-your-mac-by-solving-disk-errors-and-problems**.html) equals to the article’s title (Speed Up Your Mac By Solving Disk Errors And Problems).

    How do i achieve this? Thanks in advanced.

    # April 17, 2013 at 3:02 am

    You can do this manually with PHP. This is called a slug.

    Basically, all you have to do is switch it to lower case, remove special chars and replace spaces by dashes. :)

    [Here]( is something that should help you.

    # April 17, 2013 at 6:01 am

    There is a great script on github: [BaconStringUtilsSlugifier]( (you don’t need to use Zend to use the classes in `/src`.

    It does not only convert chars like `ö` to `o` but also `北亰` to `Bei Jing`, according to the readme (slugified that would be `bei-jing`)… You never know, right? ;)

    You then need to redirect requests to a common landing page (probably just `/index.php`, using .htaccess), read out the slug and query that page from a database (in which you have an indexed ‘unique, which is an index’ column with the slug to make queries fast).

    The `html` extension in your example doesn’t mean there is an actual html file.

    # April 17, 2013 at 6:05 am

    search in , they got what you want.

    # April 17, 2013 at 6:30 am

    thank you for all the answers guys!

    digesting the explanation…..
    reading all the links……:)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed