SitePoint Sponsor

User Tag List

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

    problem with paths after rewriting urls

    Hi,

    I was just rewriting the URLs of my site to search engine friendly ones using the PATH_INFO method (by sitepoint advice <= the first method ), so my URLs would look like example.com/article.php/beach-volley instead of example.com/article.php?id=beach-volley. However, I came across another problem: the browser won't display images that are in the root directory or in a folder of the root directory (ex. pic/ball.jpg) and the links won't work any more either. When I click on them, instead of example.com/matches.php it goes to example.com/article.php/beach-volley/matches.php, which obviously doesn't exist.

    Is there any easy way around this?

    Thanks a lot

  2. #2
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I think I figured it out, I just have to use absolute paths to files instead of relative...

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    vaj,

    I'm not sure what that link told you to do (presumably using mod_rewrite) but, if you want to learn about mod_rewrite, you might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

    In that tutorial, I discussed how changing directory levels with the mod_rewrite can destroy relative links. I offered two solution with the least desirable one being to require absolute links throughout. The preferred solution is to use HTML's <base> tag.

    I see, though, that you SHOULD have other problems with your links as using a file in a directory position in the path requires the use of MultiViews - something which has caused many problems for members over the years. To see what can (IMHO, what SHOULD) be done with article titles, have a look at http://wilderness-wally.com where I use a single file (like your article.php) to handle all the incoming links (and Wally's created dozens!). There are no MultiView problems at Wally's website.

    Oh, to answer your question, WW's website returns the Home Page (Welcome) when bad input is provided. There is a bit about this in my signature's tutorial but I don't generally elaborate (unless via PM - details can be sensitive).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •