rewrite rule

Discussion in 'Apache' started by jdanduvia, Apr 29, 2006.

  1. #1
    I have this 2 rules

    RewriteRule ^([^/.]+)/([^/.]+)$ /categories.php?secname=$1&catname=$2
    RewriteRule ^([^/.]+)$ /categories.php?secname=$1

    When i click on link first time it works fine and in url it show
    http://agile-web.com/Articles/dedicated_servers

    but now when i click on any other link the url becomes
    http://agile-web.com/Articles/Articles/Web_Hosting

    and I want
    http://agile-web.com/Articles/Web_Hosting

    each time I click on link, the url keep on increasing like above(means only last word after last '/' is replaced).

    Can anyone slove my problem?

    Thank you.
     
    jdanduvia, Apr 29, 2006 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe you want to have a leading / in those rewrite rules to make sure you get the whole URL. It's just a guess off the topof my head!

    Something like...
    RewriteRule ^/([^/.]+)/([^/.]+)$ /categories.php?secname=$1&catname=$2
    RewriteRule ^/([^/.]+)$ /categories.php?secname=$1

    If that doesn't work, let me know and I'll see if I can make some time to play with it!
     
    TwistMyArm, Apr 29, 2006 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    mod_rewrite has nothing to do with that.

    Instead of

    <a href="Articles|Web_Design" class="verdana11blackbold">Web Design</a>

    have

    <a href="/Articles/Web_Design" class="verdana11blackbold">Web Design</a>
     
    Nintendo, Apr 29, 2006 IP
  4. jdanduvia

    jdanduvia Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks, but

    RewriteRule ^/([^/.]+)/([^/.]+)$ /categories.php?secname=$1&catname=$2
    RewriteRule ^/([^/.]+)$ /categories.php?secname=$1

    didn't worked. I could not open the page.

    And to Nintendo,
    I have made

    <a href="Articles|Web_Design" class="verdana11blackbold">Web Design</a>
    this to keep the site working. Otherwise I want to do this
    <a href="/Articles/Web_Design" class="verdana11blackbold">Web Design</a>
    But this is creating problem as I mentioned before.

    Thank You.
     
    jdanduvia, May 1, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Have the full URL in the links.
     
    Nintendo, May 1, 2006 IP
  6. jdanduvia

    jdanduvia Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks Nintendo,

    The problem is solved.
     
    jdanduvia, May 1, 2006 IP