You are here:  » rewrite product URL

Support Forum



rewrite product URL

Submitted by technoarenasol on Wed, 2012-11-21 06:58 in

Hi David

I want to change Product page URL

www.example.com/mobile/nokia-302

I think change 4 places

1).htacess

RewriteRule ^(.*)$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

2)includes/tapestry.php

$config_baseHREF.urlencode(tapestry_hyphenate(strtolower($product["normalised_name"])));

3)sitemap.php

function myRecordHandler($record)
  {
    global $sitemapBaseHREF;
    global $config_useRewrite;
    if ($config_useRewrite)
    {
      $sitemapHREF = "urlencode(str_replace(" ","-",tapestry_normalise(strtolower($record["name"]))));
    }
    else
    {
      $sitemapHREF = "products.php?q=".urlencode(tapestry_normalise($record["name"]));
    }
    print "<url>";
    print "<loc>".$sitemapBaseHREF.$sitemapHREF."</loc>";
    print "</url>";
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|34");
  print "</urlset>";

tell me if any mistake or changes requires in other file...

Submitted by support on Wed, 2012-11-21 09:21

Hi Amin,

Nearly - only thing to add is in .htaccess - when using a general rule that would otherwise rewrite everything you need to include the checks for whether it is folder or file that already exists; so take this line:

RewriteRule ^(.*)$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

...and move it to the very end of .htaccess (it must be the last rule) together with the RewriteCond lines as follows:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2012-11-21 10:09

technoarenasol

Thanks David Its Working now......