mod_rewrite help

Discussion in 'Search Engine Optimization' started by manilodisan, Dec 22, 2006.

  1. #1
    I have a portal with multiple categories like PHP, ASP, Java etc. Each of this category has many other subcats. I will take an example and show you what my problem is.

    Let's take PHP which has Tutorials as one of the subcats which also has email systems as one of the subcats:

    "PHP > Tutorials > Email systems"

    If I navigate to PHP my url looks something like this:

    "http://www.rdomain.com/PHP,category,1,ID,catlistings"

    and if I navigate deeper to tutorials I get the following result:

    "http://www.domain.com/Tutorials,category,23,ID,catlistings"

    and deeper to email systems:

    "http://www.domain.com/Email_systems,category,52,ID,catlistings"

    My PHP rewrite function looks this way:

    function make_link ($baseUrl, $varArray = NULL)
      {
        global $setts;
        (string)$output = NULL;
        if ('Y' == 'Y')
        {
          while (list ($key, $value) = each ($varArray))
          {
            $value = eregi_replace (',', '', $value);
            $value = eregi_replace (' ', '-', $value);
            $value = str_replace ('\\', '', $value);
            $value = eregi_replace ('/', '', $value);
            $value = eregi_replace ('&', '', $value);
            $value = eregi_replace ('#', '', $value);
            $value = eregi_replace (';', '', $value);
            $value = eregi_replace ('&', 'and', $value);
            $value = eregi_replace ('"', '', $value);
            $output .= $value . ',' . $key . ',';
          }
    
          $output .= $baseUrl;
          return $output;
        }
    
        $output = $baseUrl . '.php';
        if ($varArray)
        {
          $output .= '?';
          while (list ($key, $value) = each ($varArray))
          {
            $output .= $key . '=' . $value . '&';
          }
        }
    
        $output = substr ($output, 0, -1);
        return $output;
      }
    
      @include_once '../catsarray.php';
      if ('Y' == 'Y')
      {
        $valsArray = explode (',', $_REQUEST['rewrite_params']);
        $valsCnt = 0;
        while ($valsCnt < count ($valsArray))
        {
          $_REQUEST[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
          $_GET[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
          $_POST[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
          $valsCnt += 2;
        }
      }
    PHP:

    ... and the .htaccess:

    RewriteEngine On
    RewriteRule ^(.*),(.*)$ $2.php?rewrite_params=$1&amp;page_url=$2


    THE PROBLEM:


    If I navigate to Email systems I want my url to contain the full path like this:

    "http://www.domain.com/PHP/Tutorials/Email_systems.html"

    I want it to finish in ".html", I also want to eliminate those commas with a "/" like in the above example.

    This should be an easy trick for someone who knows SEO but I suck so badly. Thanks for the help, if any.
     
    manilodisan, Dec 22, 2006 IP
  2. seo-mumbai

    seo-mumbai Well-Known Member

    Messages:
    2,004
    Likes Received:
    183
    Best Answers:
    0
    Trophy Points:
    105
    #2
    sorry i,am not aware of programming.They are few threads on Mod_rewrite or in programming section u get many to help u i think.
     
    seo-mumbai, Dec 22, 2006 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    What's the original url? Something like

    something.php?whatever=Email_systems&category=52&ID=catlistings
     
    Nintendo, Dec 22, 2006 IP
  4. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This is the original url of "http://www.domain.com/PHP/"



    http://www.domain.com/catlistings.php?ID=1
     
    manilodisan, Dec 23, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    What's the original URL with Email_systems,category,52,ID,catlistings

    Something like

    something.php?whatever=Email_systems&category=52&ID=catlistings

    catlistings.php?ID=1 only covers the ID part.
     
    Nintendo, Dec 23, 2006 IP
  6. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah. Everything is based on ID's and ID's only.

    if ID = parent { etc. } else { sdfsdf
    }
     
    manilodisan, Dec 26, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #7
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/([^.]+)\.html$ $1,category,$2,ID,catlistings [L]

    http://www.domain.com/Email_systems,category,52,ID,catlistings

    to

    http://www.domain.com/Email_systems/52.html

    is the only thing you can do *IF* it can work. Odds are, it won't work since you have no

    something.php?whatever=Email_systems&category=52&ID=catlistings

    info.
     
    Nintendo, Dec 26, 2006 IP
  8. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    it has to be something that invloves some coding as well nut just some rewrite rules. A function or something. I can't modify it all from .htaccess.
     
    manilodisan, Dec 27, 2006 IP