rewriting URLs - not working correctly on page redirected to

Discussion in 'Apache' started by missymee, Aug 26, 2008.

  1. #1
    I am learning about rewriting URLs and have hit a problem I can not solve.

    My menu is generated from a database which gives each page a 'nice' name. Being new to URL rewriting I haven't yet worked out how to make the rewrite match different words so all the pages are called party at the moment (but that's my next challenge/problem).

    Except for the index.php page all other pages use page.php. I have also tried this using only index.php but got even more errors.

    The URLs that show are in the form www.domain.tld/party/xx where xx is a 2 digit number.

    In my htaccess I have

    RewriteRule ^party/([0-9][0-9])/$ page.php?id=$1

    When a party/xx page is requested it knows to get the page content from the DB relevant to that category.

    When you go to index.php it appears to be all working, the URLs show in status bar with their 'nice' names when you hover over them, click on any and it takes you the right place (page.php) with the correct category id identifiable on the page (echoed at present - no main body content being pulled yet) but all the links in the menu are wrong - they all have the previous page included in them and so instead of reading www.domain.tld/party/xx they read www.domain.tld/party/xx/party/yy where xx is the category number of the link you clicked and yy is the new category number from the DB.

    I have removed the javascript in the menu in case ths was causing it but that's made no difference. Viewing the page source shows the links entered correctly, but on hover they are wrong and on clicking they go to the wrong place. Even the home link (which is handled differently and not generated from the DB) has this extra party/xx included within it.

    You can see it at www.rosharn.com/Shelly - any ideas where I am going wrong?
     
    missymee, Aug 26, 2008 IP
  2. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This isn't correct:
    Should be more like:
    (that does require a trailing slash btw)

    I'm not able to load your site...
     
    The Universes, Aug 26, 2008 IP
  3. missymee

    missymee Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you. I see the use of the + instead of matching the 2 characters individually but that doesn't actually cause it to work any differently does it? Please say if it does as it may be I have misunderstood it myself.

    The trailing slashes are in place. The site was down for a bit earlier but is back up now.
     
    missymee, Aug 26, 2008 IP
  4. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Excellent, good to see it worked for you.
     
    The Universes, Aug 26, 2008 IP
  5. missymee

    missymee Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry but no it didn't work - it made no difference what so ever and I still have the duplicated parts in the URLs.

    The only difference I can see now is that I can use any number of digits as the category number, but the URL displayed on the second page is still wrong, it is only correct on the index.php page (some categories are now single digits as I was testing the different way of matching used).
     
    missymee, Aug 26, 2008 IP