treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress URLs

  • I am working on a CMS of my own at http://html-mania.co.uk/stuff/confadarte-bikini-styles/

    I would like to make wordpress like URLs for it and i know the htaccsess part but im wondering how the PHP works.

    Could you maybe give me some starting code and ill try to do the rest.

  • @htmlmainiac You should never give out your login credentials. Especially in a community forum.

    What exactly are you trying to do? I'm not fully understanding.

  • @chrisburton

    You should never give out your login credentials. Especially in a community forum.

    Sory about that but you need them to view it and that is the only thing in that folder.

    I'm trying to make WordPress like petty permalinks.

  • You'll need to set up some mod-rewrite rules in your .htaccess file.

  • I did say i know how to do that.

    What i am asking for is the PHP side of it

  • @htmlmainiac You have to set the filename to match what you want (e.g. some-random-name.php) and then remove the .php extension. At least that's one way of doing it.

    If you're already using Wordpress, why not build a page with that?

  • @chrisburton It's for my own CMS I'm working on.

  • I still don't have what I was asking for

  • @htmlmainiac Yeah, it's best to have a little patience in the forum.

    "I want Wordpress (pretty) URL's" is not really anything to go on. We don't know how your site's URL's are structured since you don't really have any pages up except "Home" and "About". If that is the way it will be, removing the .php extension is what I suggested above.

  • @chrisburton It works but what about the query strings that's what I want it to do too.

  • htaccess isn't my area so I don't think I can help you any further. Sorry.

  • This is all about php now not htaccess

  • There are lots of ways of achieving what you want to achieve. The first is to use .htaccess to rewrite everything to index.php (except the files you want a user to access directly). You can then use something like:

    $_SERVER['REQUEST_URI']
    

    To determine their perceived URI and act upon it (remember to preserve GET request parameters).

    An alternative method, if you have a consistent and predictable structure, is to act on the URL in .htaccess to turn the URI into GET parameters. For example, Zend URLs have a very strict format:

    http://hostname/controller/action/parameters
    

    This means .htaccess can (if you want) split those components and formulate a GET request, rewriting (again) to index.php.

    However, creating a CMS is a big task. I assume you are using it as a learning experience. Unless you specifically want to learn how to construct these sorts of module, I would focus on more fundamental components first. Ugly URLs don't make your system unusable and are best addressed at or near the end, once you know the sort of information your URLs will contain.

  • Sorry -- you posted while I replied.

    This is all about php now not htaccess

    You don't seem to realise how these are connected. As I allude to above, parts of this process can be done by either. It is down to you as to which you want to use.

    Personally I favour .htaccess doing a minimal amount of work, as I think it is easier to preserve backwards compatability that way. However, if you take a look at http://camendesign.com (look at both his php and .htaccess source) you will see that he uses .htaccess heavily in his rewrites.

    Compare Kroc's .htaccess file with that of Kirby, for example:

    https://github.com/bastianallgeier/kirbycms/blob/master/.htaccess

    If you ignore the comments, it's only 13 lines (2 of which can be omitted on many servers because he's covering himself in case mod_rewrite isn't available).