jtrlho Posted July 5, 2010 Share Posted July 5, 2010 Hi!I have switched to friendly url, it all seems to work fine but in some cases it doesn't If I enter the cart the first thing when I enter my site, the cart is shown but if I first go to an item which belongs to a category it doesn't work. Below is an example of how to reproduce it:1. Go to http://sisterunika.dk/shop/ and click in the right side on "Kasse" (don't think the site is configured to run in English as well). You then see that the cart opens and it works fine.But if you then try this:1. Go to an item that belongs to a category, e.g. http://sisterunika.dk/shop/solv-smykker/32-solv-sanne.html and2. then click on "Kasse" in the right side, this error occurs:"Vi beklager, men web-adressen du indtastede er ikke længere tilgængelig" which in English means "We're sorry but the web address you've entered is no longer available".My .htaccess file looks like this: # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums # URL rewriting module activation RewriteEngine on # URL rewriting rules RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$ /shop/img/p/$1-$2$3.jpg [L,E] RewriteRule ^([0-9]+)\-([0-9]+)/([_a-zA-Z0-9-]*)\.jpg$ /shop/img/p/$1-$2.jpg [L,E] RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$ /shop/img/c/$1$2.jpg [L,E] RewriteRule ^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /shop/product.php?id_product=$3&isolang;=$1$5 [L,E] RewriteRule ^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /shop/product.php?id_product=$2&isolang;=$1$4 [L,E] RewriteRule ^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /shop/category.php?id_category=$2&isolang;=$1 [QSA,L,E] RewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /shop/product.php?id_product=$2$4 [L,E] RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /shop/product.php?id_product=$1$3 [L,E] RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /shop/category.php?id_category=$1 [QSA,L,E] RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /shop/cms.php?id_cms=$1 [QSA,L,E] RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ /shop/supplier.php?id_supplier=$1$3 [QSA,L,E] RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ /shop/manufacturer.php?id_manufacturer=$1$3 [QSA,L,E] RewriteRule ^lang-([a-z]{2})/(.*)$ /shop/$2?isolang=$1 [QSA,L,E] # Catch 404 errors ErrorDocument 404 /shop/404.php How do I fix this?Thank you. Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 The problem is that the link on that button is a relative URL. It should be an absolute URL. For some reason, {$base_dir_ssl} is empty on your site. Try switching "v1.1 theme compatibility" on or off and see whether that makes a difference. Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 HiThanks for the fast reply. I have now turned v 1.1 theme compability on but it didn't make any difference. I have also tried with the native Prestashop theme and it's the same..Do you know where I can change the relative url to absolute url?Thanks. Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 It would be better to figure out why {$base_dir_ssl} is empty, since it would fix all links instead of just the cart link. It is weird, since {$base_dir} is working on your site. I'm not sure what would cause {$base_dir_ssl} to not work. Can you attach your init.php? Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 Hi again,I greatly appreciate that you take time to help me I have attached the init.php file from our site.P.S. It seems like our site and in fact our provider (one.com) is unavailable at the moment. init.php Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 I can't see anything wrong with that file. If you've got "v1.1 theme compatibility" turned off, then it calls getHttpHost() in classes/Tools.php to get the URL. It is the following line that is getting the host part of the URL: $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); For some reason, this variable is blank on your site. Can you temporarily add the following code to one of your PHP files (index.php in the root directory, for example), refresh your website, then PM the results to me? var_dump($_SERVER); Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 Here's the output:[removed] -- Rocky Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 The 1.1. compability is turned on now by the way. Should I turn it off? Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 It depends whether your theme was designed for PrestaShop v1.1. If it was, you should leave it on, otherwise turn it off.I've copied your output and deleted your post above. It is probably a bad idea to make that information public. Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 The problem is that your server isn't including the HTTP_HOST variable in the $_SERVER array like mine does. I think you should contact your host and ask them how you can access $_SERVER['HTTP_HOST']. Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 Hi again,I have just had a long conversation with the techies at one.com. We found out that the array $_SERVER in fact includes the HTTP_HOST. I have put the following code in the index.php on our site at www.sisterunika.dk/shop. You can see the output in the top center of the page.<?phpecho $_SERVER['HTTP_HOST'];?> Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 Oh by the way - what I experience is that the cart seems to work fine with items in category level 1 but with an item in category level > 1 it seems to fail. Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 I don't understand why it isn't working then. It is the following on line 72 of classes/Tools.php that appears to be returning a blank result: $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); Can you try adding the following code after it to figure out the value of $host? echo $host; If $_SERVER['HTTP_HOST'] is working, then the only other possible problem is that $_SERVER['HTTP_X_FORWARDED_HOST'] is set, but it empty. Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 $host outputs nothingIt's the same thing with $_SERVER['HTTP_X_FORWARDED_HOST'] - also nothing.I have added the lines in the top of index.php so they are visible when entering our site at www.sisterunika.dk/shopIt seems like in the tools.php code that it should use $_SERVER['HTTP_HOST'] if $_SERVER['HTTP_X_FORWARDED_HOST'] is empty, right? Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 That's right. It seems your server is sending an empty string instead of null, which is preventing the statement from working. I suppose you could change it from: $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); to: $host = ((isset($_SERVER['HTTP_X_FORWARDED_HOST']) AND $_SERVER['HTTP_X_FORWARDED_HOST'] != "") ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); It might be a good idea to post this on the bug tracker so that PrestaShop can still function properly if an empty string is sent instead of null. Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 Hi,I have now changed the file classes\tools.php line 72 according to this: /** Ændret af Lars 06-07-2010 i samarbejde med prestashop techie: http://www.prestashop.com/forums/viewthread/61558/seo_search_engine_optimization/cart_does_not_work_with_friendly_url/ $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); */ $host = ((isset($_SERVER['HTTP_X_FORWARDED_HOST']) AND $_SERVER['HTTP_X_FORWARDED_HOST'] != "") ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); but it seems to me there's no difference.An example.. try to enter this item: http://sisterunika.dk/shop/armband/12-snehvide.html and click on Kasse in the right side. Then the url is http://sisterunika.dk/shop/armband/order.php?step=1 so it's like it includes the first category level. Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 I was trying to avoid removing the existing code, since it is probably there for a good reason. I guess you'll have to use the following instead: $host = /*(isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : */$_SERVER['HTTP_HOST']/*)*/; Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 I have also tried this: $host = $_SERVER['HTTP_HOST']; but it's the same. Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 It should work, as long as you have "v1.1 theme compatibility" mode turned off. Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 It is turned of but I still get the error.Could it be something else that's causing this behavior? Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 I can't think of anything else. The problem is that {$base_dir_ssl} is empty. It is defined on line 171 of init.php: 'base_dir_ssl' => Tools::getHttpHost(true, true).__PS_BASE_URI__, Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 This is a long shot but could it be that my provider does not support SSL..?By the way - I want you to know that I am truly thankful that you want to help me, thank you! Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 I will try to have a look at the Tools:getHttpHost tonight and see why it returns an empty string in our case. Link to comment Share on other sites More sharing options...
jtrlho Posted July 6, 2010 Author Share Posted July 6, 2010 I have called Tools:getHttpHeader from the index.php. I am a php newbie so please excuse my lack of knowledge here but the call resulted in this error: Fatal error: Class 'Configuration' not found in /customers/sisterunika.dk/sisterunika.dk/httpd.www/shop/classes/Tools.php on line 80 I don't know if it's because some file hasn't been included but I tried to remove the call to the Configuration class because I know it doesn't use SSL. My modification is here: static public function getHttpHost($http = false, $entities = false) { // Ændret af Lars 06-07-2010 i samarbejde med prestashop techie: http://www.prestashop.com/forums/viewthread/61558/seo_search_engine_optimization/cart_does_not_work_with_friendly_url/ $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); // $host = ((isset($_SERVER['HTTP_X_FORWARDED_HOST']) AND $_SERVER['HTTP_X_FORWARDED_HOST'] != "") ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); // $host = $_SERVER['HTTP_HOST']; if ($entities) $host = htmlspecialchars($host, ENT_COMPAT, 'UTF-8'); if ($http) // $host = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$host; $host = 'http://'.$host; return $host; } It returns a value and outputs it from index.php (http://sisterunika.dk) but the problem is still there. Are we looking the right place? Link to comment Share on other sites More sharing options...
rocky Posted July 7, 2010 Share Posted July 7, 2010 I'm pretty sure we are looking in the right place. The "Kasse" button is on line 116 of modules/blockcart/blockcart.tpl: <a href="{$base_dir_ssl}order.php?step=1" id="button_order_cart" class="exclusive" title="{l s='Check out' mod='blockcart'}">{l s='Check out' mod='blockcart'} The link is "{$base_dir_ssl}order.php?step=1", which should evaluate to "sisterunika.dk/shop/order.php?step=1" but it evaluating as "order.php?step=1" on your site. You could try going to the Preferences tab and changing "Enable SSL" to X, but then your site won't be protected by SSL. Link to comment Share on other sites More sharing options...
jtrlho Posted July 7, 2010 Author Share Posted July 7, 2010 SSL id disabled in the setup of our Prestashop installation. I have tried to enable it but it didn't work. I have spoken to One.com and they say that they don't support it.Do you know if we have a installation somewhere where we could verify that this is not a bug in Prestashop? It works fine when the item is placed in category level 1 but with level > 1 it fails.Could it be fixed in the new 1.4 alpha? Link to comment Share on other sites More sharing options...
rocky Posted July 7, 2010 Share Posted July 7, 2010 I think this is a server configuration issue, not a bug. You can try posting it in the bug tracker at the top of the page, but I think the PrestaShop team will say the same thing. Link to comment Share on other sites More sharing options...
Burhan BVK Posted July 7, 2010 Share Posted July 7, 2010 If you are not going to use SSL, you can edit blockcart.tpl and change {$base_dir_ssl} to {$base_dir}. That should work. Link to comment Share on other sites More sharing options...
rocky Posted July 7, 2010 Share Posted July 7, 2010 That would only fix that one link though. Every other link that uses {$base_dir_ssl} will remain broken. It would be better to go to the Preferences tab and change "Enable SSL" to "No", or if that doesn't work, change lines 130-131 of init.php from: 'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__, 'base_dir_ssl' => $protocol_link.$server_host.__PS_BASE_URI__, to: 'base_dir' => _PS_BASE_URL_.__PS_BASE_URI__, 'base_dir_ssl' => _PS_BASE_URL_./*$protocol_link.$server_host.*/__PS_BASE_URI__, Link to comment Share on other sites More sharing options...
jtrlho Posted July 10, 2010 Author Share Posted July 10, 2010 Hi rocky I have tried the suggested init.php modification but it's the same... Link to comment Share on other sites More sharing options...
rocky Posted July 10, 2010 Share Posted July 10, 2010 That should have worked. I guess you "v1.1 theme compatibility" on. Try changing lines 170-171 from: 'base_dir' => __PS_BASE_URI__, 'base_dir_ssl' => /*Tools::getHttpHost(true, true).*/__PS_BASE_URI__, Link to comment Share on other sites More sharing options...
jtrlho Posted July 10, 2010 Author Share Posted July 10, 2010 The 1.1 is off, I'll try changing lines 170-171 as well... Link to comment Share on other sites More sharing options...
jtrlho Posted July 10, 2010 Author Share Posted July 10, 2010 I have also changed the lines 170-171 but with no difference Link to comment Share on other sites More sharing options...
rocky Posted July 10, 2010 Share Posted July 10, 2010 Have you tried going to the Preferences tab and changing "Enable SSL" to "No"? I'm out of ideas. When I looked at your site, the {$base_dir} was working, but {$base_dir_ssl} wasn't. If my previous suggestions don't work, I don't know what else will. Link to comment Share on other sites More sharing options...
jtrlho Posted July 11, 2010 Author Share Posted July 11, 2010 Enable SSL is already set to "no" because my provider does not support SSL at the moment.But thank you Rocky and others for trying to help me. It's weird what's going on because I have tried to reproduce the error on the Prestashop demo page but with no luck - it worked fine. So it really seems like it's a combination of some php stuff variable'ish my provider does not support and something else.I will for the time being use non-friendly url's until hopefully some day there will be a fix for this issue.Best regards,Lars Link to comment Share on other sites More sharing options...
jtrlho Posted July 12, 2010 Author Share Posted July 12, 2010 In the meantime, I have moved our domain to gigahost because they allow customers to edit their php.ini file.I have enabled friendly url's but it still doesn't work. Any ideas what I can tweak in the php.ini file in order to make this work?Thanks! Link to comment Share on other sites More sharing options...
jtrlho Posted July 12, 2010 Author Share Posted July 12, 2010 I have tried to verify this issue when the page is running in english language and there it works. But when the language is danish it does not work.Could it be an issue in the danish translation files that's causing this issue? Link to comment Share on other sites More sharing options...
jtrlho Posted July 12, 2010 Author Share Posted July 12, 2010 Rocky: Is there a way somehow that I can debug this and possible find the error? I don't know much about php but I am quite good at learning and understanding new stuff so if you can guide me, I would appreciate it very much.I really want to nail this one because friendly url's will expose our website a lot more and we really need it. Link to comment Share on other sites More sharing options...
rocky Posted July 12, 2010 Share Posted July 12, 2010 I can think of any more debugging than what we've already tried that would help. Link to comment Share on other sites More sharing options...
jtrlho Posted July 13, 2010 Author Share Posted July 13, 2010 I think I have found the reason. When the module epay is disabled, it works. The reason I found out is that base_dir_ssl and base_dir seems to be overwritten in this module. Can someone please help me correcting this error?The code is here: <?php /* Copyright (c) 2009. All rights reserved ePay - www.epay.dk. This program is free software. You are allowed to use the software but NOT allowed to modify the software. It is also not legal to do any changes to the software and distribute it in your own name / brand. */ /* SSL Management */ $useSSL = true; include_once(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../init.php'); include_once(dirname(__FILE__).'/epay.php'); $smarty->assign('base_dir_ssl_init', $protocol_link.$server_host.__PS_BASE_URI__); /* Overriding assigned vars from init.php to reflect relay-script */ /* Server Params */ $server_host = htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8'); $protocol = EPAY::$relay_script_url; $protocol_ssl = EPAY::$relay_script_url; $protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol; $protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol; $smarty->assign(array( 'base_dir' => $protocol_link.$server_host.__PS_BASE_URI__, 'base_dir_ssl' => $protocol_link.$server_host.__PS_BASE_URI__, 'content_dir' => $protocol_content.$server_host.__PS_BASE_URI__, 'img_ps_dir' => $protocol_content.$server_host._PS_IMG_, 'img_cat_dir' => $protocol_content.$server_host._THEME_CAT_DIR_, 'img_lang_dir' => $protocol_content.$server_host._THEME_LANG_DIR_, 'img_prod_dir' => $protocol_content.$server_host._THEME_PROD_DIR_, 'img_manu_dir' => $protocol_content.$server_host._THEME_MANU_DIR_, 'img_sup_dir' => $protocol_content.$server_host._THEME_SUP_DIR_, 'img_ship_dir' => $protocol_content.$server_host._THEME_SHIP_DIR_, 'img_col_dir' => $protocol_content.$server_host._THEME_COL_DIR_, 'img_dir' => $protocol_content.$server_host._THEME_IMG_DIR_, 'css_dir' => $protocol_content.$server_host._THEME_CSS_DIR_, 'js_dir' => $protocol_content.$server_host._THEME_JS_DIR_, 'tpl_dir' => $protocol_content.$server_host._PS_THEME_DIR_, 'relative_tpl_dir' => _PS_THEME_DIR_, 'modules_dir' => $protocol_content.$server_host._MODULE_DIR_)); $smarty->assign('relay_script_url', EPAY::$relay_script_url); $css_files[$protocol_content.$server_host._THEME_CSS_DIR_.'global.css'] = 'all'; $css_files[$protocol_content.$server_host._MODULE_DIR_.'epay/css/epayment.css'] = 'all'; $js_files['epayment_checkform'] = $protocol_content.$server_host._MODULE_DIR_.'epay/js/epayment_checkform.js'; $js_files['epayment_cvc'] = $protocol_content.$server_host._MODULE_DIR_.'epay/js/jumpcvc.js'; include_once(dirname(__FILE__).'/../../header.php'); $smarty->assign('summary', $cart->getSummaryDetails()); $epay = new EPAY(); echo $epay->relayPayment(array('cart' => $cart)); include_once(dirname(__FILE__).'/../../footer.php'); ?> Thanks! Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 Just // comment out the base_dir_ssl line and see whether that fixes the problem. Link to comment Share on other sites More sharing options...
jtrlho Posted July 13, 2010 Author Share Posted July 13, 2010 The error was found in the module epay and the blockepaymentlogo.tpl file, line 8 (the first one below): {assign var='tmp' value=$base_dir_sll} {assign var='base_dir_ssl' value=$base_dir_ssl_init} {assign var='base_dir_ssl' value=$tmp} but the correct line should be: {assign var='tmp' value=$base_dir_ssl} {assign var='base_dir_ssl' value=$base_dir_ssl_init} {assign var='base_dir_ssl' value=$tmp} Case closed. Thanks Rocky and others for leading me to the solution!! :-) Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2010 Share Posted July 13, 2010 All this trouble was caused by one typo? Please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
jtrlho Posted July 13, 2010 Author Share Posted July 13, 2010 Yeah ..I understand why you couldn't find it cause it was caused by a 3rd party module :-)Thanks again, great work. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now