Page 1 of 1

Custom Rewrite Rules for osCommerce

Posted: Sun Mar 16, 2008 12:49 pm
by e-electr
Hi
I have a working site with MSU 1.1, (www.e-electronica.es) but I have created new php files. How can I build rewrite rules for this new pages and having the language delimiter working.
Now: www.e-electronica.es/warranty.php
Needed: www.e-electronica.es/en/warranty.html

I also plan to further extend my web and add way more new pages. So please give a general solution for any situation ( If posible)

Thank you,
Bye bye

P.S. Nice work with this MSU, realy nice ;)

Re: Custom Rewrite Rules for osCommerce

Posted: Sun Mar 16, 2008 1:27 pm
by inveo
You need something like this:

Code: Select all

RewriteRule ^([a-z]{2})/warranty.html$ warranty.php?language=$1 [L,QSA]

Re: Custom Rewrite Rules for osCommerce

Posted: Sun Mar 16, 2008 1:35 pm
by e-electr
Thnx for your fast answer...

I should work but is not ... I don't know why...
Any sugestions?

Thnx

Re: Custom Rewrite Rules for osCommerce

Posted: Sun Mar 16, 2008 1:39 pm
by inveo
Make sure .htaccess file is readonly. Otherwise your changes will be lost.

Re: Custom Rewrite Rules for osCommerce

Posted: Sun Mar 16, 2008 1:52 pm
by e-electr
Ok, let's say that your solution is partialy good for waht I need/whant
I will explain myself...

In my page I have a "Information" secction.....
» Who we are?
» Where we are?
» Privacy Policy
» General conditions
» Payment modalities
» Shipping and returns
» Warranty
» Contact Us

For example Warranty will link to: http://www.e-electronica.es/warranty.php
But I whant a automatic redirect to a http://www.e-electronica.es/es/warranty.html

Your solution will make available my warranty.php trough http://www.e-electronica.es/es/warranty.html. But in my page I still have a link to http://www.e-electronica.es/warranty.php
I hope you can understand my need now.
Tnkx

Re: Custom Rewrite Rules for osCommerce

Posted: Sun Mar 16, 2008 2:16 pm
by e-electr
You will understand better my need if you search for a way to automaticaly redirect: https://www.e-electronica.es/password_forgotten.php and to maintain my language structure ie: https://www.e-electronica.es/es/password_forgotten.php
I can not modify catalog/includes/boxes/Login.php for all my 5 languages. no?

Why this link is not automaticaly rewriten?
It's standard osCommerce... Well I need this rewriten plz :)

I think that what I need is for you to modify the code of MSU to adapt to my needs, becose there is no other way to do What I need.
How much for 1link added to your MSU?

Re: Custom Rewrite Rules for osCommerce

Posted: Wed Mar 18, 2009 4:04 pm
by 9827579
Has anyone solved this problem? I have got the same problem...
I have got a page: /about.php which can be accessed through /en/about.html
but I want it to be redirected to /en/about.html when typed /about.php

Re: Custom Rewrite Rules for osCommerce

Posted: Thu Mar 19, 2009 12:47 pm
by inveo

Re: Custom Rewrite Rules for osCommerce

Posted: Fri Mar 20, 2009 12:31 am
by 9827579
Ok this is clear to me, but can you give me a correct 301 redirect rule when using multilanguage mode? It does not seem to work for me....

In other words: how can I use

Code: Select all

RewriteRule ^about.php$ about.html [R=301,L,QSA]

in multilanguage?

(taken from http://www.magic-seo-url.com/board/rewrite-rules-for-zen-cart-mods-15.html

Re: Custom Rewrite Rules for osCommerce

Posted: Wed Jun 30, 2010 5:47 am
by shotputty
please read my solution for your problem below:


I made a MOD which I will post here. It works for custom pages, you only need to change the tep_href_link function in your includes/html_output.php file, and add 1 line of code per new page in your .htaccess file.

First backup!!
Then replace from
// The HTML href link wrapper function
until
return $link ; }

with this code:

Code: Select all

  ////
// The HTML href link wrapper function
  function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
    global $request_type, $session_started, $SID, $unCurrentLang  ;

    if (!tep_not_null($page)) {
      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
    }

    if ($connection == 'NONSSL') {
     $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG ;
     
     
    } elseif ($connection == 'SSL') {
      if (ENABLE_SSL == true) {
        $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
      } else {
        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
      }
    } else {
      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');
    }


//Modification for Magic Seo Url custom pages addition for OScommerce

//for each additional page add a line with a subsequent number like: $customepages_non_seo[following number] = "your_new__non_seo_name_page.php" ;
$customepages_non_seo[0] = "all_products.php" ;
$customepages_non_seo[1] = "some_products.php" ;

//for each additional page add a line with the SEO NAME YOU WANT (!) with a subsequent number like: $customepages_yes_seo[corresponding number] = "your-seo-name-for-that-page-without-extension-if-you-like" ;
$customepages_yes_seo[0] = "all-products" ;
$customepages_yes_seo[1] = "some-products" ;

//add each new page in includes/filenames.php like any other page (example): define('FILENAME_SOME_PRODUCTS', 'some_products.php');
//add catalog/your_new_file.php and includes/languages/your_new_file.php (this is basic OScommerce knowledge for adding pages)

//place 1 rule per new page in .htaccess like this:
// RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]
//change accordingly to your own names for each line you add

if (tep_not_null($parameters)) {

switch ($page) {

    case in_array($page, $customepages_non_seo) :
       $seokey = array_search($page, $customepages_non_seo); // $seokey = ''number corresponding to the page;
       $parts = explode("=",$parameters);  //break the string up around the "=" character in $mystring
 
           if ($parameters == 'language=' . $parts['1']) {
             $link .= $parts['1'] . '/' . $customepages_yes_seo[$seokey] ;
           } else {
             $link .= $unCurrentLang . '/' . $customepages_yes_seo[$seokey] . '?' . tep_output_string($parameters);
             $separator = '&';
           }
    break;




  //original code
   default:
   $link .= $page . '?' . tep_output_string($parameters);
   $separator = '&';
//end original code
}

} else {

switch ($page) {

    case in_array($page, $customepages_non_seo) :
    $seokey = array_search($page, $customepages_non_seo); // $seokey = ''number corresponding to the page;
     $link .= $unCurrentLang  . '/' . $customepages_yes_seo[$seokey] ;
     $separator = '?';
   break;



 default:
 //original code
 
  $link .= $page ;
  $separator = '?';
//end original code
}}
//end of modification for Magic Se0 Url









    while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
    if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
      if (tep_not_null($SID)) {
        $_sid = $SID;
      } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
        if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
          $_sid = tep_session_name() . '=' . tep_session_id();
        }
      }
    }

    if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
      while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

      $link = str_replace('?', '/', $link);
      $link = str_replace('&', '/', $link);
      $link = str_replace('=', '/', $link);

      $separator = '?';
    }

    if (isset($_sid)) {
      $link .= $separator . tep_output_string($_sid);
    }

    return $link ;
  }


add each new page in includes/filenames.php like any other page (example): define('FILENAME_SOME_PRODUCTS', 'some_products.php');
add catalog/your_new_file.php and includes/languages/your_new_file.php (this is basic OScommerce knowledge for adding pages)

place 1 rule per new page in .htaccess like this:
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]
change accordingly to your own names for each line you add

IMPORTANT, this code (above) contains two example filenames, you need to adjust them or add new ones according to your own pagenames!!

IMPORTANT 2: this code is setup for multilanguage, it will add the /en or /fr or /de between your url and your filename.


Cart  
(empty)

Cart Check out  »

Prices are tax inclusive.

The VAT rate for your country (US) * is 0,0 % because it is not a member of the European Union (EU).

* Please create an account if your country does not match.

Community feed
  • [Zen Cart] Can't execute Magic SEO URLs sitemaps
    I installed Magic SEO URLs Sitemaps Add-On for ZenCart MSU4.x/MSU5.x 2.0 on my server, when I try to generate sitemaps using: https://www.pechesudv155.owally.com/sitemaps.php I received :...
    by peter@pechesud.com
  • [phpBB3] Sharing users between phpBB / PrestaShop
    Hi i have 2 question 1- prestashop module support phpBB 3.3 ? 2- why we can not login in prestashop and phpbb with same user?
    by zohall
  • [phpBB3] AJAX Userinfo Extension
    Hi! I'm having trouble with this extension: https://www.phpbb.com/customise/db/exte ... _userinfo/ I tried asking support from the author but for no avail, since now. My request for support...
    by Lord Phobos
  • [phpBB3] Upgrade to phpBB 3.2.3
    Hello.. after Upgrade to phpBB 3.2.3 I am getting this message.. How can I solve this issue..? Thank you
    by ingbrzy
  • [phpBB3] URL path changed
    Hello.. I have changed my site path after moving to new hosting and now can not activate SEO module.. new path http://www.miuios.cz/domains/miuios.cz/ could you help me? thank you
    by ingbrzy2
Join our support forum » Pre-Sales Questions »
Featured Testimonials

Thanks for a wonderful product, works great with phpBB3. Thanks for the prompt support.

Ravi, the owner of Sharesguru

Skeptical at first as I am with all new purchases that can dramatically effect traffic, but this one comes highly recommended. And not just for the product, the support is second to none and all issues are dealt with politely and efficiently. Top Marks!

Phillip, the owner of Sexy Ladies Fancy Dress Costumes

More Testimonials »