-
path routing problem with the hosting
Everything starts from this post https://www.zen-cart.com/showthread....search-instead where eventually even another has the same problem of path path
I have a problem that the hosting service can not resolve, I hope that you will. I stress before it all runs on localhost MAMP but not on the hosting, I made a change this
(https://pro-webs.net/blog/2010/03/21...tock-products/)
I get a debug file and rederict not work why?
PHP Code:
[03-May-2016 13:29:29 Europe/Rome] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/balblabla/public_html/includes/templates/mobishop_blue/common/tpl_header.php:230) in /home/balblabla/public_html/includes/modules/pages/product_info/main_template_vars.php on line 34
[03-May-2016 13:29:29 Europe/Rome] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/balblabla/public_html/includes/templates/mobishop_blue/common/tpl_header.php:230) in /home/balblabla/public_html/includes/modules/pages/product_info/main_template_vars.php on line 35
[03-May-2016 13:29:29 Europe/Rome] PHP Warning: require(/home/balblabla/public_html/includes/templates/mobishop_blue/templates): failed to open stream: No such device in /home/balblabla/public_html/includes/modules/pages/product_info/main_template_vars.php on line 180
[03-May-2016 13:29:29 Europe/Rome] PHP Fatal error: require(): Failed opening required 'includes/templates/mobishop_blue/templates' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/balblabla/public_html/includes/modules/pages/product_info/main_template_vars.php on line 180
I think that hosting has some restrictions but which one? they tell me that the code is wrong, but if it works in localhost as may be the Melanie code?
-
Re: path routing problem with the hosting
Did you change the path from the localhost to the hosting server?
Also remove try changing
PHP Code:
.:/usr/lib/php:/usr/local/lib/php
To
PHP Code:
/usr/lib/php:/usr/local/lib/php
See if that helps
-
Re: path routing problem with the hosting
Hello, thanks for the reply but I do not understand where to change .:/usr/lib/php:/usr/local/lib/phpphp of MAMP which is on the pc runs and sur hosting that hosts the site that does not work , and hosting manager does not know what to do to blame the code that I try to put in /includes/modules/pages/product_info/main_template_vars.php
-
Re: path routing problem with the hosting
the idea that it works in MAMP does not necessarily mean it will work with your hosting company. configuration of shared web servers can be difficult and complex.
that said, it's pretty clear your redirect is not working. post the code for your redirect. i would make use of the included function zen_redirect which would ensure that the proper configuration gets used (and should work on both your MAMP and on the shared server).
-
Re: path routing problem with the hosting
It is what he said the assistance is not guaranteed to work with us. You can not be a little more clear what I should do maybe where to intervene Thanks
the code is this
In /includes/modules/pages/product_info/main_template_vars.php around line 31 find:
if ( $res->fields['total'] < 1 ) {
Just below this you will see
$tpl_page_body = '/tpl_product_info_noproduct.php';
Replace this line with
$requeststring = (isset($_GET['cPath']))?'&cPath='. (int)$_GET['cPath']:'';
header( "HTTP/1.1 301 Moved Permanently" );
header('location:index.php?main_page=index'.$requeststring);
-
Re: path routing problem with the hosting
the error is here:
No such device in /home/balblabla/public_html/includes/modules/pages/product_info/main_template_vars.php on line 180
please post line 180.
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
carlwhat
the error is here:
No such device in /home/balblabla/public_html/includes/modules/pages/product_info/main_template_vars.php on line 180
please post line 180.
It will be helpful to anyone trying to assist you if you could post the code for that line. Also and this may be a silly question. What is the purpose of the redirect? This may be helpful to understand your issue better.
-
Re: path routing problem with the hosting
Sorry for the delay in the response decalage time, place the entire file and the line 180.
The aim is that if a file does not exist in the DB instead of having an error 302 to a 404 face a rederict 301 to a specific page
HTML Code:
require($template->get_template_dir($tpl_page_body,DIR_WS_TEMPLATE, $current_page_base,'templates'). $tpl_page_body);
HTML Code:
<?php
/**
* product_info main_template_vars.php
*
* @package productTypes
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Fri Jul 6 11:57:44 2012 -0400 Modified in v1.5.1 $
*/
/*
* Extracts and constructs the data to be used in the product-type template tpl_TYPEHANDLER_info_display.php
*/
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_PRODUCT_INFO');
$module_show_categories = PRODUCT_INFO_CATEGORIES;
$sql = "select count(*) as total
from " . TABLE_PRODUCTS . " p, " .
TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
$res = $db->Execute($sql);
if ( $res->fields['total'] < 1 ) {
$requeststring = (isset($_GET['cPath']))?'&cPath='. (int)$_GET['cPath']:'';
header( "HTTP/1.1 301 Moved Permanently" );
header('location:index.php?main_page=featured_products'.$requeststring);
} else {
$tpl_page_body = '/tpl_product_info_display.php';
$zco_notifier->notify('NOTIFY_PRODUCT_VIEWS_HIT_INCREMENTOR', (int)$_GET['products_id']);
$sql = "select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
$product_info = $db->Execute($sql);
$products_price_sorter = $product_info->fields['products_price_sorter'];
$products_price = $currencies->display_price($product_info->fields['products_price'],
zen_get_tax_rate($product_info->fields['products_tax_class_id']));
$manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);
if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
$specials_price = $currencies->display_price($new_price,
zen_get_tax_rate($product_info->fields['products_tax_class_id']));
}
// set flag for attributes module usage:
$flag_show_weight_attrib_for_this_prod_type = SHOW_PRODUCT_INFO_WEIGHT_ATTRIBUTES;
// get attributes
require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ATTRIBUTES));
// if review must be approved or disabled do not show review
$review_status = " and r.status = '1'";
$reviews_query = "select count(*) as count from " . TABLE_REVIEWS . " r, "
. TABLE_REVIEWS_DESCRIPTION . " rd
where r.products_id = '" . (int)$_GET['products_id'] . "'
and r.reviews_id = rd.reviews_id
and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'" .
$review_status;
$reviews = $db->Execute($reviews_query);
}
require(DIR_WS_MODULES . zen_get_module_directory('product_prev_next.php'));
$products_name = $product_info->fields['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
$products_description = (!preg_match('/(<br|<p|<div|<dd|<li|<span)/i', $product_info->fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
if ($product_info->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
$products_image = PRODUCTS_IMAGE_NO_IMAGE;
} else {
$products_image = $product_info->fields['products_image'];
}
$products_url = $product_info->fields['products_url'];
$products_date_available = $product_info->fields['products_date_available'];
$products_date_added = $product_info->fields['products_date_added'];
$products_manufacturer = $manufacturers_name;
$products_weight = $product_info->fields['products_weight'];
$products_quantity = $product_info->fields['products_quantity'];
$products_qty_box_status = $product_info->fields['products_qty_box_status'];
$products_quantity_order_max = $product_info->fields['products_quantity_order_max'];
$products_base_price = $currencies->display_price(zen_get_products_base_price((int)$_GET['products_id']),
zen_get_tax_rate($product_info->fields['products_tax_class_id']));
$product_is_free = $product_info->fields['product_is_free'];
$products_tax_class_id = $product_info->fields['products_tax_class_id'];
$module_show_categories = PRODUCT_INFO_CATEGORIES;
$module_next_previous = PRODUCT_INFO_PREVIOUS_NEXT;
$products_id_current = (int)$_GET['products_id'];
$products_discount_type = $product_info->fields['products_discount_type'];
$products_discount_type_from = $product_info->fields['products_discount_type_from'];
/**
* Load product-type-specific main_template_vars
*/
$prod_type_specific_vars_info = DIR_WS_MODULES . 'pages/' . $current_page_base . '/main_template_vars_product_type.php';
if (file_exists($prod_type_specific_vars_info)) {
include_once($prod_type_specific_vars_info);
}
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_PRODUCT_TYPE_VARS_PRODUCT_INFO');
/**
* Load all *.PHP files from the /includes/templates/MYTEMPLATE/PAGENAME/extra_main_template_vars
*/
$extras_dir = $template->get_template_dir('.php', DIR_WS_TEMPLATE, $current_page_base . 'extra_main_template_vars', $current_page_base . '/' . 'extra_main_template_vars');
if ($dir = @dir($extras_dir)) {
while ($file = $dir->read()) {
if (!is_dir($extras_dir . '/' . $file)) {
if (preg_match('~^[^\._].*\.php$~i', $file) > 0) {
$directory_array[] = '/' . $file;
}
}
}
$dir->close();
}
if (sizeof($directory_array)) sort($directory_array);
for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
if (file_exists($extras_dir . $directory_array[$i])) include($extras_dir . $directory_array[$i]);
}
// build show flags from product type layout settings
$flag_show_product_info_starting_at = zen_get_show_product_switch($_GET['products_id'], 'starting_at');
$flag_show_product_info_model = zen_get_show_product_switch($_GET['products_id'], 'model');
$flag_show_product_info_weight = zen_get_show_product_switch($_GET['products_id'], 'weight');
$flag_show_product_info_quantity = zen_get_show_product_switch($_GET['products_id'], 'quantity');
$flag_show_product_info_manufacturer = zen_get_show_product_switch($_GET['products_id'], 'manufacturer');
$flag_show_product_info_in_cart_qty = zen_get_show_product_switch($_GET['products_id'], 'in_cart_qty');
$flag_show_product_info_reviews = zen_get_show_product_switch($_GET['products_id'], 'reviews');
$flag_show_product_info_reviews_count = zen_get_show_product_switch($_GET['products_id'], 'reviews_count');
$flag_show_product_info_date_available = zen_get_show_product_switch($_GET['products_id'], 'date_available');
$flag_show_product_info_date_added = zen_get_show_product_switch($_GET['products_id'], 'date_added');
$flag_show_product_info_url = zen_get_show_product_switch($_GET['products_id'], 'url');
$flag_show_product_info_additional_images = zen_get_show_product_switch($_GET['products_id'], 'additional_images');
$flag_show_product_info_free_shipping = zen_get_show_product_switch($_GET['products_id'], 'always_free_shipping_image_switch');
require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCTS_QUANTITY_DISCOUNTS));
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_EXTRA_PRODUCT_INFO');
require($template->get_template_dir($tpl_page_body,DIR_WS_TEMPLATE, $current_page_base,'templates'). $tpl_page_body);
//require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_ALSO_PURCHASED_PRODUCTS));
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_END_PRODUCT_INFO');
-
Re: path routing problem with the hosting
Quote:
The aim is that if a file does not exist in the DB instead of having an error 302 to a 404 face a rederict 301 to a specific page
First off "files" do not exist in the DB
Why don't you leave the ZenCart code alone?
Use htaccess for what you are seeking
-
Re: path routing problem with the hosting
... or, you could try using the built-in Zen Cart functions to perform your task. Change
Code:
$res = $db->Execute($sql);
if ( $res->fields['total'] < 1 ) {
$requeststring = (isset($_GET['cPath']))?'&cPath='. (int)$_GET['cPath']:'';
header( "HTTP/1.1 301 Moved Permanently" );
header('location:index.php?main_page=featured_products'.$requeststring);
} else {
to
Code:
$res = $db->Execute($sql);
if ( $res->fields['total'] < 1 ) {
zen_redirect (zen_href_link (FILENAME_FEATURED, (isset ($_GET['cPath'])) ? ('cPath=' . (int)$_GET['cPath']) : ''), 301);
} else {
-
Re: path routing problem with the hosting
Hello Lat9 I tried your solution but it does not change I always have a 404, sorry I can not translate my thoughts. What I mean is that the server does not make the rederict with the first explained solution in this site https://pro-webs.net/blog/2010/03/21...tock-products/ but localhos works on PCs with MAMP except online. Instead the Lat9 solution does not work online and in local host.
Kobra, zen cart solution makes me a redirect 302 to a 404, but since I have many products obselet the best solution in my case would be a collective 301 final.
-
Re: path routing problem with the hosting
diamond1,
my mistake. line 180 is not the culprit. the first error (warning) in the log states line 34 which is where the headers/redirect code is.
i would make the change as indicated by lat9 above.
ok, i'm seeing that did not work. i had a feeling it would not. the problem is that the header information has already been sent here:
includes/templates/mobishop_blue/common/tpl_header.php:230
which means the redirect would need to come before that line of code.
in looking at that file in the default template, the code is much smaller... maybe post that and lets see if we can move the redirect there.
best.
-
Re: path routing problem with the hosting
230 in the line of tpl_header.php files I have this
PHP Code:
</div>
<?php require(DIR_WS_MODULES . $template_dir . '/categories_popup.php');
echo $content; ?>
</div>
-
Re: path routing problem with the hosting
i'm sorry, you have posted 4 lines of code. which one specifically is line 230?
perhaps post the whole file. unless the $content has the headers info in there.
-
Re: path routing problem with the hosting
Sorry
PHP Code:
<?php
/**
* Template designed by 12leaves.com
* 12leaves.com - Free ecommerce templates and design services
*
* Common Template
*
* @package languageDefines
* @copyright Copyright 2009-2010 12leaves.com
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_header.php 4813 2006-10-23 02:13:53Z drbyte $
*/
?>
<?php
// Display all header alerts via messageStack:
echo '<div class="messages-st">';
if ($messageStack->size('header') > 0) {
echo $messageStack->output('header');
}
if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) {
echo htmlspecialchars(urldecode($_GET['error_message']));
}
if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
echo htmlspecialchars($_GET['info_message']);
} else {
}
echo '</div>';
// test if box should display
$show_languages= true;
if ($show_languages == true) {
if (!isset($lng) || (isset($lng) && !is_object($lng))) {
$lng = new language;
}
reset($lng->catalog_languages);
$languages_array = array();
$current_language = '';
while (list($key, $value) = each($lng->catalog_languages)) {
$languages_array_popup[$key] = $value['name'];
}
foreach ($languages_array_popup as $k => $v){
if ($k == $_SESSION['languages_code']) {
$current_language = $v;
}
}
}
?>
<!--bof-header logo and navigation display-->
<?php
if (!isset($flag_disable_header) || !$flag_disable_header) {
?>
<div id="headerWrapper">
<!--bof-branding display-->
<div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div>
<!--eof-branding display-->
<div>
<!--bof-header ezpage links-->
<div class="topper-menu float-right hidden-phone">
<?php if (EZPAGES_STATUS_HEADER == '1' or (EZPAGES_STATUS_HEADER == '2' and (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])))) { ?>
<?php require($template->get_template_dir('tpl_ezpages_bar_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_ezpages_bar_header.php'); ?>
<?php } ?>
</div>
<!-- Languages/currency -->
<div class="languages-wrapper">
<div class="top-item visible-phone">
<a id="menu_more" class="item-icon" href="#"> </a>
<div id="menu_more_popup" class="popup popup-win pull-right">
<img class="close-pic float-right" src="<?php echo ($template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images'). '/close_pic.gif'); ?>" alt="close" />
<!--bof-header ezpage links-->
<?php if (EZPAGES_STATUS_HEADER == '1' or (EZPAGES_STATUS_HEADER == '2' and (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])))) { ?>
<?php require($template->get_template_dir('tpl_ezpages_bar_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_ezpages_bar_header.php'); ?>
<hr />
<?php } ?>
<?php if ($_SESSION['customer_id']) { ?>
<a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a><br />
<a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a>
<?php
} else {
if (STORE_STATUS == '0') {
?>
<a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a>
<?php } } ?>
<!--eof-header ezpage links-->
</div>
</div>
<?php
$languges_object = new language;
if (count ($languges_object->catalog_languages) > 1){
?>
<div class="languages">
<?php require($template->get_template_dir('tpl_languages_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_languages_header.php'); ?>
<div id="langPopup" class="popup popup-win">
<img class="close-pic float-right" src="<?php echo ($template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images'). '/close_pic.gif'); ?>" alt="close" />
<?php require(DIR_WS_MODULES . zen_get_module_directory('header_languages.php')); ?>
</div>
</div>
<?php
}
?>
<?php
if (isset($currencies) && is_object($currencies) && count ($currencies->currencies) > 1){
?>
<div class="currency">
<?php require($template->get_template_dir('tpl_currency_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_currency_header.php'); ?>
<div id="currPopup" class="popup popup-win">
<img id="close-pic" class="close-pic float-right" src="<?php echo ($template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images'). '/close_pic.gif'); ?>" alt="close" />
<ul class="list-popup">
<?php foreach ($currencies_array_popup as $k=>$v) { ?>
<li><a href="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); if ((stripos($_SERVER['REQUEST_URI'], '.php')) === false ) { echo "?";} else {echo "&"; }?><?php echo 'currency='.$k; ?>"><?php echo $v; ?></a></li>
<?php }?>
</ul>
</div>
</div>
<?php
}
?>
</div>
<!--eof-header ezpage links-->
<div class="clearRight"></div>
<?php
require($template->get_template_dir('tpl_top_nav.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_top_nav.php');
?>
<?php
if ($this_is_home_page) {
if (SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
}
?>
</div>
<div class="clearBoth"></div>
<!-- tools section -->
<div class="tools-wrp">
<div id="tools_wrapper" class="align-center">
<div id="search-panel">
<div class="float-left td-search-header">
<div class="search-header float-left">
<?php require($template->get_template_dir('tpl_search_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_search_header.php');?>
<div class="advanced_search float-left">
<a href="index.php?main_page=advanced_search"><?php echo HEADER_ADVANCED_SEARCH; ?></a>
</div>
</div>
</div>
<div class="cart-header-wrapper">
<!-- header cart section -->
<table class="align-center cart-header">
<tr>
<td></td>
<td class="cart-img-td">
<?php require($template->get_template_dir('tpl_shopping_cart_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_shopping_cart_header.php');
echo $content;?>
</td>
<td id="delim"></td>
<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
<td class="orange-link">
<a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a>
</td>
<?php } else { ?>
<td class="blue-link">
<a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a>
</td>
<?php } ?>
</tr>
</table>
</div>
</div>
</div>
<!-- mobile header -->
<div id="top_nav_mobile">
<div id="tab_nav_mobile">
<ul class="list-style-none">
<li class="tm-catalog <?php echo $active;?>">
<span class="dlm"></span>
<a id="catalog"><?php echo '<img src="'. $template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images') . '/spacer.gif" width="50" height="50" alt="" />'; ?></a>
</li>
<?php
if ($current_page_base == 'account' || $current_page_base == 'login' || $current_page_base == 'account_edit' || $current_page_base == 'address_book' || $current_page_base == 'account_password' || $current_page_base == 'account_newsletters' || $current_page_base == 'account_notifications') { $active = 'tab-active';
} else { $active = '';
}?>
<li class="tm-account <?php echo $active;?>"><span class="dlm"></span><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo '<img src="'. $template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images') . '/spacer.gif" width="50" height="50" alt="" />'; ?></a></li>
<?php
if ($current_page_base == 'shopping_cart') { $active = 'tab-active'; $item_id = '';
} else { $active = ''; $item_id = 'cart-icon';
}?>
<li class="tm-cart <?php echo $active;?>"><span class="dlm"></span>
<a class="<?php echo $item_id; ?>" href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo '<img src="'. $template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images') . '/spacer.gif" width="50" height="50" alt="" />'; ?>
<?php if ($product_amount > 0) { ?><span class="cart-amount"><?php echo $product_amount; ?></span><?php } ?>
</a>
</li>
<?php
if ($current_page_base == 'advanced_search') { $active = 'tab-active';
} else { $active = '';
}?>
<li class="tm-search <?php echo $active;?>"><span class="dlm"></span><a href="index.php?main_page=advanced_search"><?php echo '<img src="'. $template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images') . '/spacer.gif" width="50" height="50" alt="" />'; ?></a></li>
</ul>
</div>
<?php require(DIR_WS_MODULES . $template_dir . '/categories_popup.php');
echo $content; ?>
</div>
<!-- /mobile header -->
<!-- cart popup -->
<div id="cart_popup" class="cart-dropdown-wrapper popup">
<div class="cart-tab-wrapper"><img src="<?php echo $template->get_template_dir('', DIR_WS_TEMPLATE, $current_page_base,'images')?>/spacer.gif" width="1" height="1" alt="" /></div>
<div class="popup-border">
<div class="content-wrapper">
<div class="cart-scrolling-wrapper">
<?php require($template->get_template_dir('tpl_shopping_cart_popup.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_shopping_cart_popup.php');
echo $content; ?>
</div>
<div class="popup-cart-link-box">
<a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL')?>"><?php echo CART_POPUP_VIEW_CART; ?></a>
<a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a>
</div>
</div>
</div>
</div>
<!-- /cart popup -->
</div>
<!-- /tools section -->
</div>
<?php } ?>
-
Re: path routing problem with the hosting
line 230 is:
<?php require(DIR_WS_MODULES . $template_dir . '/categories_popup.php');
i do not believe:
categories_popup.php
is part of the base package. and i am unfamiliar with this template and what that script does. you can try commenting that line out as such:
<?php //require(DIR_WS_MODULES . $template_dir . '/categories_popup.php');
but i am not sure if that will work nor what other cascading effect it may have. you can try it and see what happens.
also, please post your website URL.
best.
-
Re: path routing problem with the hosting
Thanks for the reply, I have a responsive template and
PHP Code:
<?php require(DIR_WS_MODULES . $template_dir . '/categories_popup.php');
It serves to open the pop-up categories.
Even if I give you the link of the website you can not see the error that because I can not apply the code to the site if it does not work. But again I say, in localhost the code works does a rederict 301 to ppagina that imposed if the product does not exist, then I think it's a setting you want to modify or adapt the code to the server / includes / modules / pages / product_info / main_template_vars .php
-
Re: path routing problem with the hosting
Quote:
zen cart solution makes me a redirect 302 to a 404, but since I have many products obselet the best solution in my case would be a collective 301 final.
The following in a htaccess will redirect any non file/missing page to your index.php page
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,QSA]
</IfModule>
-
Re: path routing problem with the hosting
Hello Kobra, it's okay I put nell'htaccess, but I would like to understand why it does not work the 301 and I get a double-header in response to live instead in localhost does rederict. Then how come if I have a product that does not exist I get a 302 to a 404 error as I think it is not normal ricere an error 302 to a 404.
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
diamond1
Hello Kobra, it's okay I put nell'htaccess, but I would like to understand why it does not work the 301 and I get a double-header in response to live instead in localhost does rederict. Then how come if I have a product that does not exist I get a 302 to a 404 error as I think it is not normal ricere an error 302 to a 404.
i can think of a few reasons why it works in your localhost and not in live. first would be the difference in the configuration of the server. second would be the data in your database is different on your localhost v the live server. third, the code on the 2 machines, which you think is the same, may be different.
-
1 Attachment(s)
Re: path routing problem with the hosting
I can not get out of this situation, I tried but nothing seems to zencart does everything to give a 302 and then 404 as an error if the product does not even exist in the online demo is always a rederict 302 to 404. This is not normal and is probably the cause of my problems that I can not get rid of products exist where I can not make a rederict 301. But where there is a url rewriting of the 404 works well does not make the first 302 is directly as a 404 error.
I hope someone will give me the solution. Thanks Gio
Here's an example of a demo of zencart where product ID does not exist from a 302 and then a 404 something completely useless to give a 302 before.
https://www.zen-cart-pro.net/templat...ducts_id=34522
Attachment 16321
-
Re: path routing problem with the hosting
Recently I helped someone to do a sort of redirect. The first attempt also was to modify the main_template_vars file because it made sense as that was where the data was "determined" to be correct, but a similar issue occurred (headers already sent). This has to do with the sequence of information loaded and that such a redirect (at least a specific one like you are trying to do) ought to be handled in the header related file(s). While the responsive template may have some factor in the issue, my suggestion would be to do your test/check in the header_php.php file before the notifier at the end and redirect from there.
Now I am not aware of what all else is going on regarding the 302/404 issue, which seems to be a unique problem to the software/server side. There has been discussion about possible differences between your live site and your local one, but no identification of specifically those differences. I suggest that you find a comparison tool and identify any differences between the two sites including but not limited to the contents of each file as well as files that exist on one server and not the other. In some cases, and often, names of files are changed to make them "old" but the change does not prevent the file from loading because of the file's extension and the location in which it remains. Feel free to post the filenames and discrepancies to obtain further assistance.
-
Re: path routing problem with the hosting
Hello MC thank you for answering, I can understand everything but admit chese if a product does not exist instead of getting a 404 I get before a rederict 302. This has affected me for years since I removed the rewrite url. Now I've lost so many location on google ranking that I wonder why no one talks about it and nobody knows what to do to remove this rederict 302 before getting a 404.
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
diamond1
Hello MC thank you for answering, I can understand everything but admit chese if a product does not exist instead of getting a 404 I get before a rederict 302. This has affected me for years since I removed the rewrite url. Now I've lost so many location on google ranking that I wonder why no one talks about it and nobody knows what to do to remove this rederict 302 before getting a 404.
This is information that was not previously provided (among a number of other things that would lead to a solution). First of all, ZC (at least currently) only uses a 302 redirect within the paypalwpp.php file.... So, any 302 redirect other than an issue with paypal processing is brought on by something else on your system. One way to try to identify what code exists on your server that may offer the 302 redirect is from your admin, goto tools->Developers toolkit, then in the bottom left fill in 302, select catalog on the dropdown, then search... Haven't spoken about what version of ZC you are currently using, or perhaps so and I haven't gone through all of the posts specifically for that tidbit, but that search should identify includes/modules/payment/paypalwpp.php as having a 302 redirect and perhaps whatever else is causing yours. The next thing is that you said you "removed the rewrite url", you haven't identified which one was installed, and more than likely remnants of that url rewriter still exist on your system and that is a large part of what you are experiencing.
The why others haven't? Well, they haven't come across the issue, haven't looked, or when they have attempted to do what is stated above about removal of the software they were successful at fully removing it. It is again one reason why the upgrade process (BTW 1.5.5.a is out now) suggests basically to do a clean install of the software, integrate the needed plugins and other minor software modifications so that old/unused plugins don't interact.
-
Re: path routing problem with the hosting
Hello MC, has nothing to do with the 1.5.5a version, if you see all of the online demo version have the probleme, that if a product id does not exist does not provide a 404 but first a 302 and then a 404 as an error. as far as my version is a new 1,5,4 never did a rewrite url. I ask you to check the link above to me and you'll see that makes a 302 before and after going to page 404
-
Re: path routing problem with the hosting
diamond1,
Did you search using the developers tool kit for "302"??
If so, what were the results?
-
Re: path routing problem with the hosting
Hello Kobra, No rederict 302 apart on paypalwpp.php file. But this does not justify why it does, if you see any zencart demo we have the same result ie if the product does not exist does a 302 and then a 404 even if we do not find other header ("HTTP / 1.1 302 Object Moved"); apart on paypal
-
Re: path routing problem with the hosting
So had done a little research yesterday, but thing is I was having difficulty finding one piece of the puzzle. Have you confirmed that the 302 followed by 404 occurs even as the first visit to the site? I ask because of some of the standard operations that occur.
Generally speaking I found only two places that really addressed the "missing product" condition. The first that a guest is expected to come across is the sanitizer. But the conditions of the sanitizer appear to not play a factor on first visit, though I didn't look to see if the sanitizer is double run by ZC. So, if run once per "page" load, then on first visit it sets a session variable that would be used later to do a different action.
The second place found as related to the specific url provided was the header_php.php for product_info (includes/modules/pages/product_info/header_php.php) where the "first" line checks if the product exists and if not modifies the header to provide a 404.
So then, one asks, so whee's the 302? Well, a header sent with a location like is used to redirect will without other direction issue a 302 based on the php.net documentation on the header function. But, in the above process of establishing a "first" visit or as seen/detected by a SE which is not supposed to get an established session, there does not appear to be an action that would so automatically issue the 302 (no redirect action that would do/cause that). The only thing that appears could cause a 302 to be issued with a 404 in a non-session based visit is settings on the server that issue a 302 when a 404 is issued which based on the limited read of the php manual on the header function are either server based or controllable by the php.ini.
In summary, a "white-hat" SE or a recognized one will not start a session and therefore will not see the 302 of a redirect because of a non-existent product, but instead see the 404 as provided by the settings of the host server making the 302 followed by 404 a non-issue for such "visitors" but instead something seen by those with a session like a browsing customer.
-
Re: path routing problem with the hosting
Mc, I did not understand it is the fault of the server settings of the php.ini file? so those using zen cart have this problem of 302 before 404? How to avoid this?
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
diamond1
Mc, I did not understand it is the fault of the server settings of the php.ini file? so those using zen cart have this problem of 302 before 404? How to avoid this?
So I think you missed the bigger picture, but to be sure. What is it about the 302/404 that you as a visitor that is not indexing or ranking your site but see this response are trying to correct or prevent?
As to the "settings" at the moment all I have is what I found while reviewing the php manual on the header function regarding the special case of say an http/ request.
-
Re: path routing problem with the hosting
If it is a server setting in the php.ini file then it is most likely this
Code:
; cgi.rfc2616_headers configuration option tells PHP what type of headers to
; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
; is supported by Apache. When this option is set to 1 PHP will send
; RFC2616 compliant header.
; Default is zero.
;cgi.rfc2616_headers = 0
You should determine if your host allows a local php.ini file to adjust settings and if so have them provide you with what is currently loaded with php from there one can adjust settings
-
Re: path routing problem with the hosting
i find this conversation interesting on a number of levels.
#1 - kobra, i attempted this change on a test server, and it did not solve the problem. i changed the value in my php.ini file, restarted apache and i still got a 302/404 response codes.
#2 - i am NOT convinced that sending a 302 then a 404 is per se a problem. as i have found that:
"The HTTP response status code 302 Found is a common way of performing URL redirection."
#3 - mc, interesting research. i'm not sure i follow it all, but at the end of the day, i can not get my test server to NOT send the 302 response. and it strikes me, no doubt as part of the server setup or something else in some configuration value.
#4 - i looked at a couple of shopify sites as well as a woo-commerce site, and neither one of those sites sends the 302 prior to the 404.
i'm not sure where that leaves us. i have verified and reproduced the behavior, i do not see the same behavior on other carts, & finally i'm not convinced that it is a problem per se.
hmmm.....
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
carlwhat
i find this conversation interesting on a number of levels.
#1 - kobra, i attempted this change on a test server, and it did not solve the problem. i changed the value in my php.ini file, restarted apache and i still got a 302/404 response codes.
#2 - i am NOT convinced that sending a 302 then a 404 is per se a problem. as i have found that:
"The HTTP response status code 302 Found is a common way of performing URL redirection."
#3 - mc, interesting research. i'm not sure i follow it all, but at the end of the day, i can not get my test server to NOT send the 302 response. and it strikes me, no doubt as part of the server setup or something else in some configuration value.
#4 - i looked at a couple of shopify sites as well as a woo-commerce site, and neither one of those sites sends the 302 prior to the 404.
i'm not sure where that leaves us. i have verified and reproduced the behavior, i do not see the same behavior on other carts, & finally i'm not convinced that it is a problem per se.
hmmm.....
In your test to not get the 302, did you force yourself to be viewed as a bot? Ie to not have a session get started?
The 302 as a visitor is somewhat expected after a session has been started because in the initial load process of a page, the sanitizer looks to see about a few settings, but the first time it is encountered (or upon reload of the same page) it sets a session value to true. When the code is then run again for the case of an errant products_id, then with that session value being true a redirect is performed which because it is a generic redirect it issues a 302 based on a standard header redirect as described in the php manual. That redirect takes the "visitor" to the applicable info page (more than likely products_info) where the header file checks for the existence of the products_id and when found not present issues a 404. So... that's in the case of a session being started.
But... bots... which supposedly include search engines... they are not to have a session. Therefore, the sanitizer is expected to never see the session setting that would allow the redirect based on a bad products_id and therefore they get immediately sent to the products_info page and therefore only a 404 is issued without the intermediate redirect/302...
That is if I understood all that is/was going on even though I didn't do a line-by-line review and used what I have come to understand about sessions, bots, and recently the sanitizer. :)
-
Re: path routing problem with the hosting
ok. again, mc, i appreciate your work. i always learn something when reading your posts. thank you.
i did not force myself to be a bot. i came on as i normally do. and frankly, as i previously documented, the behavior is different in other shopping carts. which makes it more curious here.
let's solve the puzzle. the problem is not with the sessions. the "problem" is in everyone's favorite script:
includes/init_includes/init_sanitize.php
i am not sure why that script validates the products_id and then performs a redirect. validating of the product_id happens in the includes/modules/pages/product_info/header_php.php; and from there the 404 happens. why ZC also does it in the sanitizer, you got me. perhaps, when i have a moment, i will issue a PR to see.
anyways, find this bit of code in the init_sanitize.php (around line 125); comment out the redirect; and the behavior should be straight 404, no 302.
please let me know if it works.
PHP Code:
/**
* validate products_id for search engines and bookmarks, etc.
*/
if (isset($_GET['products_id']) && isset($_SESSION['check_valid']) && $_SESSION['check_valid'] != 'false') {
$check_valid = zen_products_id_valid($_GET['products_id']);
if (!$check_valid) {
$_GET['main_page'] = zen_get_info_page($_GET['products_id']);
/**
* do not recheck redirect
*/
$_SESSION['check_valid'] = 'false';
// COMMENT OUT THE NEXT LINE!
//zen_redirect(zen_href_link($_GET['main_page'], 'products_id=' . $_GET['products_id']));
}
} else {
$_SESSION['check_valid'] = 'true';
}
best.
-
Re: path routing problem with the hosting
Hello MC thanks for the time that I spend an iced coffee merits, if you tell me what comment I can try if it works
-
Re: path routing problem with the hosting
There still remains the question of what is meant by "it works"...
The sanitizer as I see it at least in this regards, identifies that if the products_id is amiss by someone (not something) navigating the site, then perhaps there is something else that is amiss and therefore it recreates the path that is the next destination in a way that ignores whatever was previously provided. Ie. It sanitizes the content. Afterall, what site would itself display a link to a product that is on the site but isn't an existing product? Little mobius strip there... that's one of the things about maintaining security is identifying where things could be wrong and take an action that is appropriate.
If anything it seems to me that the 302 followed by 404 for someone that is not a recognized search engine or a bot is more of a misunderstood condition than anything. Why is it a goal to remove the 302 I wonder. It's considered a temporary redirect and in this case the result is a 404 page. Okay, so what say you that the last products_id in the store is 180. Now someone tries 181. Nothing there. So should there be a 301 instead? Oops, now products_id 181 is added, but that's a non-existent product from the previous permanent redirection, so what's going on? Is it really a permanent redirect or is it something that should be temporary?
So regarding the line that carlwhat suggested commenting out, if there still was a true need to prevent a valid visitor (session being started) from receiving a 302 and instead some other status code, then I would actually modify that line to have it provide the desired end status code of choice for a product not existing in the catalog. The modification merely would only require adding a comma and the status code just before the last right parenthesis of that line. I still don't see the value in concerning oneself with the response code seen by such a valid visitor/user.
I expect that as a visitor being issued a session that commenting out the above code will prevent the 302 from being issued, but it also removes any sanitization offered by that line moving forward. So I would suggest if you only want a 404 to be issued to anyone/everyone and everything that visits the site using an invalid/unknown products_id then to change the line to:
Code:
zen_redirect(zen_href_link($_GET['main_page'], p'products_id=' . $_GET['products_id']), '404');
it will cause two 404s to be issued to those for which it doesn't matter either way, but at least no 302 and no indicator that it is permanently gone.
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
mc12345678
There still remains the question of what is meant by "it works"...
The sanitizer as I see it at least in this regards, identifies that if the products_id is amiss by someone (not something) navigating the site, then perhaps there is something else that is amiss and therefore it recreates the path that is the next destination in a way that ignores whatever was previously provided. Ie. It sanitizes the content. Afterall, what site would itself display a link to a product that is on the site but isn't an existing product? Little mobius strip there... that's one of the things about maintaining security is identifying where things could be wrong and take an action that is appropriate.
If anything it seems to me that the 302 followed by 404 for someone that is not a recognized search engine or a bot is more of a misunderstood condition than anything. Why is it a goal to remove the 302 I wonder. It's considered a temporary redirect and in this case the result is a 404 page. Okay, so what say you that the last products_id in the store is 180. Now someone tries 181. Nothing there. So should there be a 301 instead? Oops, now products_id 181 is added, but that's a non-existent product from the previous permanent redirection, so what's going on? Is it really a permanent redirect or is it something that should be temporary?
So regarding the line that carlwhat suggested commenting out, if there still was a true need to prevent a valid visitor (session being started) from receiving a 302 and instead some other status code, then I would actually modify that line to have it provide the desired end status code of choice for a product not existing in the catalog. The modification merely would only require adding a comma and the status code just before the last right parenthesis of that line. I still don't see the value in concerning oneself with the response code seen by such a valid visitor/user.
I expect that as a visitor being issued a session that commenting out the above code will prevent the 302 from being issued, but it also removes any sanitization offered by that line moving forward. So I would suggest if you only want a 404 to be issued to anyone/everyone and everything that visits the site using an invalid/unknown products_id then to change the line to:
Code:
zen_redirect(zen_href_link($_GET['main_page'], p'products_id=' . $_GET['products_id']), '404');
it will cause two 404s to be issued to those for which it doesn't matter either way, but at least no 302 and no indicator that it is permanently gone.
Sorry in trying to edit the text to remove #s I accidentally pressed a letter causing my above recommended code snippet to be wrong. It should have been:
Code:
zen_redirect(zen_href_link($_GET['main_page'], 'products_id=' . $_GET['products_id']), '404');
-
Re: path routing problem with the hosting
Hello Mark Thanks I appreciate what you're doing and you're almost there, it works but I get a blank page if the product id does not exist, but if I do a page refresh then you see.
-
Re: path routing problem with the hosting
Quote:
Originally Posted by
diamond1
Hello Mark Thanks I appreciate what you're doing and you're almost there, it works but I get a blank page if the product id does not exist, but if I do a page refresh then you see.
A blank page should generate an error log in the logs directory. Not sure what action above was taken/tried, but I do know the code I had in one of the previous posts included a letter p next to a quote which would cause an error in such a "test".
-
Re: path routing problem with the hosting
Not by any error in the log folder, do a refresh and the page you see, the strange thing is that if I see the source of the blank page I see that there's a whole page but not displayed.
-
1 Attachment(s)
Re: path routing problem with the hosting
I forgot my screen
Attachment 16334
-
Re: path routing problem with the hosting
ok. i can going to humbly disagree.
ZC needs to keep it simple. the sanitizer is for sanitizing variables. period. it should not redirect. if a product is in-active and hence not displayed, ZC should generate a 404 without a redirection. session, no session; it should not matter.
the OP said this was an issue dealing with his google ranking and he thinks its because of the 302 to 404. i can not say if his ranking is hurt due to the redirection; i can only say redirecting to a 404 makes zero sense. if no session is started, MC says this behavior would not happen. i can not say. i can only say that this behavior is wrong. and commenting out that line addresses the problem. it does absolutely nothing with regards to ZCs sanitizing of variables. you come to page with a product that does not exist or that is inactive; don't have google or anyone else index the page. sanitize the variables and give them the 404.
i have read no argument in this thread that warrants further discussion, IMHO, as to why that redirect is there. unless someone can convince me otherwise, i see no reason for it to be there; nor for changing it to a 404 and then another 404.
it's the sanitizer. sanitize the variables. move on. keep it simple.
as far as it not working for diamond1, i tested it on a vanilla install of v160. works fine. i tested it on my development v155 with lots of other plugins and modified templates, also works fine. if it does not work for him, i can not say what the problem might be. i'm sure some troubleshooting could address it.
as further proof of why i think this is wrong, lets say a ZC store created a new product type, with a new display page. someone went to this page:
index.php?main_page=product_awesome_info&products_id=164025566
it would generate a 302, and then ZC redirects to:
index.php?main_page=product_info&products_id=164025566
where a 404 gets generated.
now if the ZC store owner wanted different 404 pages shown for the different product types, he could not do it all because of the redirect. and the ZC store owner would even need to change the redirect code in the sanitizer associated with this unneeded redirect.
best.