SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MOD Rewrite from php to HTML

    hello,
    Even though i joined sometime ago and I am new to this I have a problem which i was looking all around for sometime for some tips on specific modrewrite examples/tips but am unable to get it to work. here is what i want to do

    I want
    mysite . com / index . php ? type = limestones & fileid = 130

    to convert to
    mysite . com / limestones / name-of-the-stones . html

    I managed to do
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^stones/([^/]+)/([^/]+) . html /index . php?action=$1&id=$2 [NC]

    this but this doesn't do what i exactly want and show as the images are missing. I am pretty knew to rewrite rules and would appericate any guidance.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the browser is having trouble rendering the html page because it cannot load the images, then you need to alter the html.

    If the url in the browser address bar is
    mysite . com / limestones / name-of-the-stones . html

    Then the browser will resolve any relative urls using
    mysite . com / limestones /
    as the base.

    Eg, if you have an <img src="images/foo.jpg"> then the browser will look for the image at
    mysite . com / limestones /images/foo.jpg

    Personally, I like using absolute urls, although I use the shorthand.
    absolute: src="http://example.com/images/foo.jpg"
    or src="/images/foo.jpg"

    Note the leading /, the browser treats this as being absolute, but for the same domain that its currently on.

  3. #3
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you for your reply. very helpful. so there is no rewrite rule set a base for these image or templates ? I think i'll try the way you explained.

    one thing about the urls, i am not actually getting the urls exactly that way either. the way i am getting the url is
    mysite . com / limestones / 130 . html

    but i'd like it to be
    mysite . com / limestones / name-of-the-stone . html

    i read in apache modrewrite that you could pass anything after the FILEID ( $2 ) and make it look like
    mysite . com / limestones / 130-name of the stone .html

    but i am yet to find an example for this and i am actually shooting for more like
    mysite . com / limestones / name-of-the-stone . html
    or
    mysite . com / limestones / name-of-the-stone-130 . html

    is there any rule to convert "the stone name" ( fileid = $2 ) to a "name-of-thes-tone" ?

    i'd appericaite any kind of tips on these.
    Last edited by BNetwork; Apr 4, 2009 at 12:12. Reason: add more details


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
  •