Bonjour tout le monde,
j'espére que les fetes ont été bonne pour tout le monde :wink:
je suis nouveau sur le forum, mais je sens que je vais devenir un habitué
voila donc ma question =>
je suis en train d'effectuer de l'url rewriting sur mon site internet, tout fonctione exepté quelques petites choses.
j'utilise comme séparateur le -
et voici mes problèmes =>
* si un article est appelé alors qu'il contient un - dans son nom, IE m'affiche impossible d'afficher la page
* ensuite je n'arrive pas a supprimer les caractéres spéciaux comme ()'&%$ etc... ce qui me fait des %2B et autres dans l'url sur certain produits.
Donc comment puis je remedier a ce problème.
voici mon .htaccess en test
ensuite voici le contenu de mon fichier rewrite.php
et le fichier effectuant l'affichage html_output.php
la fonction qui j'utilise pour supprimer les caractéres accentués et celle ci
Je travail depuis plusieurs jour sur ce problème mais impossible de trouver une solution. Ce qui est normal car je ne suis pas un pro du php :lol:
Donc j'attend vos avis, etc... tout ce qui puisse me faire avancé dans mon shmilblic... (excusé moi pour l'orthographe).
Merci d'avance et bonne fete de fin d'année a tous.
++
j'espére que les fetes ont été bonne pour tout le monde :wink:
je suis nouveau sur le forum, mais je sens que je vais devenir un habitué
voila donc ma question =>
je suis en train d'effectuer de l'url rewriting sur mon site internet, tout fonctione exepté quelques petites choses.
j'utilise comme séparateur le -
et voici mes problèmes =>
* si un article est appelé alors qu'il contient un - dans son nom, IE m'affiche impossible d'afficher la page
* ensuite je n'arrive pas a supprimer les caractéres spéciaux comme ()'&%$ etc... ce qui me fait des %2B et autres dans l'url sur certain produits.
Donc comment puis je remedier a ce problème.
voici mon .htaccess en test
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /test
RewriteRule admin - [L]
RewriteRule test$ /test/index.php [R,L]
RewriteRule test/$ /test/index.php [R,L]
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !^/$
RewriteRule !\.(gif|php|css|js|jpg)$ /test/rewrite.php
RewriteRule .* - [F]
ensuite voici le contenu de mon fichier rewrite.php
Code:
<?php
include('includes/application_top.php');
if ($REQUEST_URI == '/catalog/') {
tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
if ($REQUEST_TYPE == 'SSL') {
$comparison_array = explode('/', HTTPS_SERVER . DIR_WS_HTTPS_CATALOG, 4);
} else {
$comparison_array = explode('/', HTTP_SERVER . DIR_WS_HTTP_CATALOG, 4);
}
$comparison = $comparison_array[3];
$parts = explode('?', str_replace($comparison, '', $REQUEST_URI), 2);
$list = explode('/', preg_replace(array('#^/#', '#/$#'), '', $parts[0]));
if (sizeof($parts) == 2) {
$parameters = explode('&', $parts[1]);
foreach ($parameters as $pair) {
$pieces = explode('=', $pair);
$HTTP_GET_VARS[$pieces[0]] = $pieces[1];
}
}
$current_category_id = 0;
$cPath_array = array();
$count = 0;
foreach ($list as $piece_encoded) {
$count++;
$piece = urldecode(preg_replace(array('/[-]/', '/%20/'), array(' ', '%2F'),$piece_encoded));
if ($piece == 'catalog') {
continue;
}
$query_string = "select cd.categories_id from categories_description cd, categories c where cd.categories_id=c.categories_id and cd.categories_name='" . tep_db_input($piece) . "' and c.parent_id='" . (int)$current_category_id . "'";
$category_query = tep_db_query("select cd.categories_id from categories_description cd, categories c where cd.categories_id=c.categories_id and cd.categories_name like '" . tep_db_input($piece) . "' and c.parent_id='" . (int)$current_category_id . "'");
if ($category_array = tep_db_fetch_array($category_query)) {
$cPath_array[]= $category_array['categories_id'];
$breadcrumb->add(mrpropre($piece), tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', $cPath_array)));
$current_category_id = $category_array['categories_id'];
} else {
if ($current_category_id != '0') {
$parent_where_string = " and p2c.categories_id='" . (int)$current_category_id . "'";
} else {
$parent_where_string = '';
}
$product_query = tep_db_query("select pd.products_id from products_description pd, products_to_categories p2c, products p where p.products_id = pd.products_id and p.products_status = '1' and pd.products_id=p2c.products_id and pd.products_name='" . tep_db_input($piece) . "'" . $parent_where_string);
if ($product_array = tep_db_fetch_array($product_query)) {
if (sizeof($cPath_array) < 1) {
$cPath = tep_get_product_path($product_array['products_id']);
$cPath_array = explode('_', $cPath);
for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
$categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
if (tep_db_num_rows($categories_query) > 0) {
$categories = tep_db_fetch_array($categories_query); $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
} else {
break;
}
}
} else {
$cPath = implode('_', $cPath_array);
}
$breadcrumb->add(mrpropre($piece), tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $product_array['products_id']));
$HTTP_GET_VARS['products_id'] = $product_array['products_id'];
$PHP_SELF_REWRITE = mrpropre(dirname($PHP_SELF)) . '/' . FILENAME_PRODUCT_INFO;
$PHP_SELF = mrpropre($PHP_SELF_REWRITE);
include(FILENAME_PRODUCT_INFO);
exit();
} else {
$manufacturer_query = tep_db_query("select manufacturers_id from manufacturers where manufacturers_name='" . tep_db_input($piece) . "'");
if ($manufacturer_array = tep_db_fetch_array($manufacturer_query)) {
$breadcrumb->add(mrpropre($piece), tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', $cPath_array) . 'manufacturers_id=' . (int)$manufacturers_array['manufacturers_id']));
$HTTP_GET_VARS['manufacturers_id'] = $manufacturer_array['manufacturers_id'];
if ($count == sizeof($list)) {
$HTTP_GET_VARS['filter_id'] = $current_category_id;
$PHP_SELF_REWRITE = mrpropre(dirname($PHP_SELF)) . '/' . FILENAME_DEFAULT;
$PHP_SELF = mrpropre($PHP_SELF_REWRITE);
$cPath = implode('_', $cPath_array);
$HTTP_GET_VARS['cPath'] = $cPath;
include(FILENAME_DEFAULT);
exit();
}
} else {
reset($list);
/* tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keywords=' . implode('+', $list))); */
}
}
}
}
$cPath = implode('_', $cPath_array);
$HTTP_GET_VARS['cPath'] = $cPath;
$PHP_SELF_REWRITE = mrpropre(dirname($PHP_SELF)) . '/' . FILENAME_DEFAULT;
$PHP_SELF = $PHP_SELF_REWRITE;
include(FILENAME_DEFAULT);
?>
et le fichier effectuant l'affichage html_output.php
Code:
<?php
// 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;
$separator = '?';
if (tep_not_null($parameters)) {
$product_name = '';
switch ($page) {
case FILENAME_PRODUCT_INFO:
case FILENAME_DEFAULT:
$manufacturer_name = '';
$product_name = '';
$new_parameter_list = array();
$cPath_list = array();
foreach (explode('&', $parameters) as $pair) {
global $languages_id;
$pair_array = explode('=', $pair);
switch ($pair_array[0]) {
case 'action':
$link .= $page . '?' . tep_output_string($parameters);
$separator = '&';
break 3;
case 'cPath':
$parent_id = 0;
foreach (explode('_', $pair_array[1]) as $category_id) {
$category_name_query = tep_db_query("select cd.categories_name from categories_description cd, categories c where cd.categories_id=c.categories_id and cd.categories_id='" . (int)$category_id . "' and cd.language_id='" . (int)$languages_id . "' and c.parent_id='" . (int)$parent_id . "'");
if ($category_name_array = tep_db_fetch_array($category_name_query)) {
$cPath_list[]= urlencode(strtolower(mrpropre($category_name_array['categories_name'])));
$parent_id = $category_id;
}
}
break;
case 'products_id':
$product_name_query = tep_db_query("select products_name from products_description where products_id='" . (int)$pair_array[1] . "' and language_id='" . (int)$languages_id . "'");
if ($product_name_array = tep_db_fetch_array($product_name_query)) {
$product_name = strtolower(mrpropre($product_name_array['products_name']));
}
break;
case 'manufacturers_id':
$manufacturer_name_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id='" . (int)$pair_array[1] . "'");
if ($manufacturer_array = tep_db_fetch_array($manufacturer_name_query)) {
$manufacturer_name = strtolower(mrpropre($manufacturer_array['manufacturers_name']));
}
break;
case '':
break;
default:
if (tep_not_null($pair)) $new_parameter_list[]= $pair;
}
}
if (tep_not_null($manufacturer_name)) {
$cPath_list[]= urlencode($manufacturer_name);
}
if (tep_not_null($product_name)) {
$cPath_list[]= urlencode($product_name);
}
$separator = '?';
$link .= preg_replace(array('/%2F/', '/[+]/'), array('%20', '-'), implode('/', $cPath_list));
if (tep_not_null($new_parameter_list)) {
$link .= $separator . implode('&', $new_parameter_list);
$separator = '&';
}
break;
default:
$link .= $page . '?' . tep_output_string($parameters);
$separator = '&';
}
} else {
$link .= $page;
$separator = '?';
}
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 . $_sid;
}
return $link;
}
?>
la fonction qui j'utilise pour supprimer les caractéres accentués et celle ci
Code:
function mrpropre($chaine){
$tofind = "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
$replac = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn";
return(strtr($chaine,$tofind,$replac));
}
Je travail depuis plusieurs jour sur ce problème mais impossible de trouver une solution. Ce qui est normal car je ne suis pas un pro du php :lol:
Donc j'attend vos avis, etc... tout ce qui puisse me faire avancé dans mon shmilblic... (excusé moi pour l'orthographe).
Merci d'avance et bonne fete de fin d'année a tous.
++