Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    htaccess image url

    Okay, so I currently have a php script set up to do something with an image. I call the script by saying:
    Code:
    http://eli-white.com/lastfm/index.png?user=thesavior01
    I want to call it by saying:

    Code:
    http://eli-white.com/lastfm/thesavior01.png
    How do i get about doing this?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    If enabled, mod_rewrite

    Something like

    RewriteEngine on
    RewriteRule ^http://eli-white.com/lastfm/index.png?user=(.*)$ http://eli-white.com/lastfm/$1\.png

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    shouldnt it be the other way around? what it is => what it translates to?

    so if .htaccess is in the same folder as index.png it would be:

    RewriteEngine on
    RewriteRule ^(.*)\.png index.png?user=$1

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Probably. Give it a shot

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    Meh, its not working properly, somehow my script is getting "index" from the user variable. im pretty confident its not my script that is the problem.

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Where's the dollar sign that indicates end line, slashes for directories...?
    I'm not used to seeing these without that.
    Did you intend to leave them out?
    Last edited by nikkiH; 10-05-2007 at 09:13 PM.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Let me make sure I have this correctly.

    You want to re-write this url:
    http://eli-white.com/lastfm/thesavior01.png

    To this:
    http://eli-white.com/lastfm/index.png?user=thesavior01

    And this didn't work:
    RewriteEngine on
    RewriteRule ^/lastfm/(.*)\.png$ /lastfm/index.png?user=$1 [R]

    And this didn't work:
    RewriteEngine on
    RewriteRule ^/lastfm/(.*)\.png$ /lastfm/index.png?user=$1 [QSA,R]

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #8
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    all of your statements are correct.

    and none of that worked.

    I know for a fact that mod_rewrite is on.


  •  

    Posting Permissions

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