www.webdeveloper.com
Results 1 to 7 of 7

Thread: Clean URLs

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Location
    Texas
    Posts
    76

    Clean URLs

    I've been looking for tutorials and/or examples on how to change a messy url into a nice looking one.

    Like:
    http://example.com/index.php?type=ar...itten=20020322

    Goes to:
    http://example.com/article/200203226

    The ones I found don't give enough detail to start and just kinda expect you to know some stuff first. Anyone know a site?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Indiana, USA
    Posts
    79
    Maybe something like this? Should be a start anyway.

    Code:
    <?
    
    $clean_url = 'http';
    if ($_SERVER["HTTPS"] == "on") {
       $clean_url .= "s";
    }
    $clean_url .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
       $clean_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
    } else {
       $clean_url .= $_SERVER["SERVER_NAME"];
    }
    
    echo $clean_url."/";
    foreach($_GET as $key => $val){
       echo $val."/";
    }
    ?>

  3. #3
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    To clarify, you want a user to be able to type in http://example.com/article/200203226 and see the content currently at http://example.com/index.php?type=ar...itten=20020322 ?

    Is the site running on apache? or IIS?
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  4. #4
    Join Date
    Jul 2010
    Location
    Texas
    Posts
    76
    Sorry to the mods for having to move this, but thanks.

    @Ht1815, I don't even know where to put that. I feel that my php skills have improved quite a bit since joining this forum but I still lack in certain areas.

    @Svidgen, I guess that's what I'm wanting. I also want to be able to send them to http://example.com/article/200203226 from urls embedded in my pages... for SEO purposes... I believe the site is currently running IIS 7.0 it's a godaddy hosted site, with a windows hosting package (I'd like to switch to linux but the guy who owns the account is stubborn)

  5. #5
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    IIS has a GUI for setting this sort of thing up. You can write some rules in .htaccess/mod_rewrite format initially, if you like, and then import them into IIS.

    The mod_rewrite rule might look something like this:
    Code:
    ^article/([0-9]+)$ index.php?ArticleID=$1  [L,QSA]
    ... But, it might be easiest just to open the IIS administration app and start poking around in the URL rewriting area.
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  6. #6
    Join Date
    Jul 2010
    Location
    Texas
    Posts
    76
    I guess I need to really look into changing the host account to a linux because godaddy doesn't allow any changes to the IIS besides blocking directories.

    I don't even understand this mod_rewrite thing, any idea where I should go to learn about stuff like that?

  7. #7
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Umm ... I'm not sure about tutorials or how-tos. But, Apache has its own documentation on the matter: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles