Results 1 to 5 of 5

Thread: htaccess clean URL help

  1. #1
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default htaccess clean URL help

    I have been attempting to get my urls more friendly. I have been reading on using the .htaccess mod_rewrite to do this, but have been unable to get anything to work.....other than disabaling my thumbnails.

    I have been trying to change this

    http://funigifs.com/pp/index.php?showimage=9

    To this

    http://funigifs.com/pp/image/image-nine-title

    I recently found somthing about adding some php code to pages, and am still reading on that. Any information would be greatly appreciated.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    http://www.dynamicdrive.com/forums/s...ad.php?t=51923

    I just summarized the long thread today-- see the last post for the 'simple' version.

    I don't know if that will help you, but it would get around the complexity of htaccess. You'll need to include the right image format headers so that PHP serves the images as images rather than text, if that's necessary.


    If you don't want to do it that way (you want to use the traditional approach with htaccess), then you will have some major problems with that desired URL: "-title" is confusing: do you want this displayed on the page? That'll mean using another get variable like &title=title.
    Or if you just want to drop that, it'll mean more parsing to get it out of the way.
    Same with "image-"... you'll have to remove this... why have it in the first place?
    And the biggest problem is 'nine'-- can you not use numerals? You'll have to add a lot of complex regex rules for replacing spelled out numbers with numerals. The same applies in PHP, though you'll have more options there.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks, im gonna check out that other thread you suggested.

    As for the( image-nine-title )


    WHat I meant by that is replace that with the current title of the page.

    Example:

    http:funigifs.com/pp/index.php?showimage=60
    would be
    http:funigifs.com/pp/image/Cat-runs-up-slide

    http:funigifs.com/pp/index.php?showimage=13
    would be
    http:funigifs.com/pp/image/Dog-chases-car

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ah, that makes a lot more sense.
    However, this still is going to present a major problem: htaccess isn't going to know how to redirect based on "title". So I suggest that you use .htaccess like in my link or in a more traditional method that forwards the /image-title part as ?image=image-title to the PHP page.
    Then use $_GET['image'], compare it to your database (or other list) and use the right image.

    You're looking at two separate problems: 1. how do you change the url, 2. how do you convert the image title to the image filename?

    Is there some reason you don't want to save the images with those filenames? You could convert from lowercase with underscores (image_title.jpg) to capitalized with dashes: Image-Title, or whatever you'd like.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Well, I think im startin to get some were after reading your tutorial. Thanks a bunch.


    I really don't care if - or _ is used. Mainly just want something nicer looking. If I can get it to look something like http:/funigifs.com/pp/image/60 that would be a great start while I read up on the subject.

Bookmarks

Posting Permissions

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