1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Apache -> Nginx rewrite assistance request

Discussion in 'Off Topic' started by Coop1979, Jun 20, 2012.

  1. Coop1979

    Coop1979 Well-Known Member

    To make a long story short, I have an osCommerce installation that has been running on an Apache server for years using osCommerce's "Search Engine Friendly links" so that the links look like product_info.php/products_id/26 instead of product_info.php?products_id=26.

    Well, now I've moved to an Nginx server with PHP5 and the Search Engine Friendly links just won't work for me now. BUT I have links all across the web pointing to my shop using the "friendly" links, so I have to figure out a way to redirect any url that is like this:
    Code:
    product_info.php/products_id/26
    into this
    Code:
    product_info.php?products_id=26
    and
    Code:
    index.php/cPath/19
    into
    Code:
    index.php?cPath=19
    and
    Code:
    product_info.php/cPath/19/products_id/207
    into
    Code:
     product_info.php?cPath=19&products_id=207
    Anyone good with Nginx rewrite rules, or who knows how to make the osCommerce built-in SEO urls work with Nginx? The osCommerce urls don't require any htaccess rewrite rules; it looks like it's all taken care of using PHP code.
     
  2. Adam Howard

    Adam Howard Well-Known Member

  3. Coop1979

    Coop1979 Well-Known Member

    I appreciate the link, but there weren't any htaccess rewrite rules to begin with. I think it was all done in this php code:

    PHP:
    // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
      
    if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
        if (
    strlen(getenv('PATH_INFO')) > 1) {
          
    $GET_array = array();
          
    $PHP_SELF str_replace(getenv('PATH_INFO'), ''$PHP_SELF);
          
    $vars explode('/'substr(getenv('PATH_INFO'), 1));
          for (
    $i=0$n=sizeof($vars); $i<$n$i++) {
            if (
    strpos($vars[$i], '[]')) {
              
    $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
            } else {
              
    $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
            }
            
    $i++;
          }
     
          if (
    sizeof($GET_array) > 0) {
            while (list(
    $key$value) = each($GET_array)) {
              
    $HTTP_GET_VARS[$key] = $value;
            }
          }
        }
      }
     
  4. Adam Howard

    Adam Howard Well-Known Member

    From your 1st post, you never said that it was the actual php that was generating things. That will be hard.... I actually suck at getting nginx to play nice with seo friendly links. Sorry. Hopefully someone will know better than myself.
     

Share This Page