Magento Checkout - Unsecure Image - magento

I was having a problem with my Magento checkout whereby the browser was reporting that the page wasn't fully encrypted. I had a look and realised that one of the images was using http://
This is the code I was using to display the image:
getSkinUrl('images/search_button.png') ?>
As a temporary solution I have hard coded the full path to the image ie:
https://mysite.com/skin/frontend/default/mytheme/images/search_button.png
Does anyone how I can call the image dynamically but have it use https on the checkout and other secure pages?

That should be solved by using the '_secure' parameter.
$this->getSkinUrl('images/search_button.png', array('_secure' => true));

Have you set your admin config settings to "use secure" (I can't remember the exact wording) for the frontend? If so, have you set your secure URLs to be HTTPS?
Magento generates image and link URLs via those secure/unsecure URLs you specify. If you haven't properly specified those as https://, you will have this problem. Otherwise, Magento is actually very good about outputting only secure content.
I haven't tested this for skin URLs, but for regular URLs you can do the following to force secure URLs. This is from the deep bowels of the URL code:
// Get the URL for another action on our current controller
// and force it to https
$path = "*/*/submit";
$url = Mage::getUrl($path, array('_forced_secure' => true));
There's probably some way to specify those extra arguments in getSkinUrl...

Related

Firebase hosting seo friendly url

I'm using firebase hosting for my blog
I use this
mydomain.com/?postid=how_to_etc
Method to get my post data
Is there any way to use SEO friendly url like,
mydomain.com/how_to_etc
So that this link should not redirect to 404 error page
This kind of behavior requires rewrites configured with a single page app to interpret the URL path for its own router. this does depend on your current setup to determine the final work required.
alternatively, if you are using simple HTML; you can look at window.location properties and split the path with split.("/") to determine the path . See:
https://developer.mozilla.org/en-US/docs/Web/API/Location

Sitemap to use HTTPS - Magento

I am currently experiencing some problems with my Google search implementation due to a recent change to HSTS for my entire shop.
How can I create a Google sitmeap in Magento which uses the 'https://' links instead of 'http://' ?
I have already deleted my sitemap and generated a new one. It still suses http:// links.
In Google search console I see that only 8 of my 45 sites have been indexed so far..
Appreciate your help!
The sitemap links are generated using the {{unsecure_base_url}}. Make sure you change this value from http://yoursite.com to https://yoursite.com found at System->Configuration->Web Unsecure Base URL. Also, make sure both Use Secure URLs in Frontend and Backend options are set to "Yes".

mydomain.example redirect to mydomain.example/store for Magento store

I currently have a domain landing page which I want to get rid of. The landing page (mydomain.example) links to a blog and a Magento store (mydomain.example/store) but I want to the domain to link directly to the Magento store.
I set up a redirect using my hosting company's domain redirect tool on mydomain.example to mydomain.example/store, but this results in a redirect loop mydomain.example/store/store/store/store etc.
Should I be setting up a redirect anyway? It makes more sense to me to just set my Magento storefront as mydomain.example and get rid of the /store on every page within the store.
I decided that a redirect was not the answer here, so I moved the Magento store from the subdirectory /store to root. I followed these instructions:
http://www.crucialwebhost.com/kb/move-magento-to-another-directory/
But I copied files from store rather than moved them. This way you can revert back quickly if anything goes wrong.
Simply create index.html that contain this meta tag.
<meta http-equiv="Refresh" content="1; url=http://www.example.com/store">
Change example.com to your domain.
First you need to add jQuery core library and jQuery Cookies library on your WordPress site:
jQuery Library
jQuery Cookie library
Then use this jQuery code in the header.php file.
var redirectStore = jQuery.cookie("redirect");
if(redirectStore!="yes") {
jQuery.cookie("redirect", "yes",{path:'/'});
window.location= "http://www.mydomain.example/store";
}
It is checking if a "redirect" cookie is already created or not. First time users will not have this cookie. Then it redirect to mydomain.example/store and creates the cookie. If the user comes back to blog site while visiting store then it will find the redirect cookie to prevent an infinite loop.

Relative baseurl in magento

I am wanted to know that if there any settings in magento that we can remove fixed baseurl and keep dynamic(Relative) baseurl such as drupal.
It's not possible to have a relative base URL, but there's a good tutorial how to set base URL by an ini file in case of live/staging. You could adapt this to your needs:
http://maglife.co.uk/2009/03/28/magento-base-urls-and-devstaging-installations/
I would change it to read the base url from an Apache variable, which you could set per virtual host or directly read it from $_SERVER['HTTP_HOST'].
I have found that Magento sometimes will return an incorrect protocol (HTTP/HTTPS). To bypass this I've used hard-coded relative protocol URLs in certain cases (in phtml templates only) instead of calling functions.

Magento getProductUrl() is always returning HTTP

Even when I am on HTTPS, Magento's getProductUrl() always seem to return an HTTP URL. Any ways I can make this auto-switch to HTTPS? (or have it return relative protocol url).
I would say it's a rather 'standard' configuration.
Base URL is http://example.com/
Secure URL is https://example.com/
Use Secure URLs in Frontend is No
Base Link URL is {{unsecure_base_url}}
I am aware I could change the above to {{secure_base_url}} however I do not want to force a change from HTTP to HTTPS, I only need it to stay relative.
The main Magento's benefit, is that you can do anything you want with it :) So, yes, you can output HTTPS product urls or relative ones. However, before choosing a solution, let's consider the Magento authors' vision.
The HTTPS for frontend is designed to work only for specific areas like Customer account, Payment methods, Checkout, etc. There is nothing so private about products, which makes it necessary to be viewed via HTTPS as well.
By default Magento doesn't use HTTPS even for pages, mentioned above. In order to turn HTTPS on, the "Use Secure URLs in Frontend" option must be set to "Yes". Which, as described, will engage HTTPS only in limited set of pages that contain some private data.
So the best solution for you depends on specifics of the store, you are developing.
1) If you want to engage HTTPS for all the pages on frontend - then the best solution is to put "https://..." into "Base URL" option for "Unsecure" web url configuration.
2) If you want to turn on HTTPS only for product links and only for a limited number of pages, then you can override templates of that pages in order to put there relative urls. The actual code can be implemented in any way you like, even the simplest already proposed way is ok:
echo trim($_product->getProductUrl(),'http:')
3) If you want to engage HTTPS for all the product links at frontend - then the best way is to override Mage_Catalog_Module_Product_Url model and change method getUrl() - you need to put there
$routeParams['_secure'] = true;
This will produce all the product urls with HTTPS protocol.
4) If you need to show HTTP product links only at HTTP pages and HTTPS product links only at HTTPS pages, then you can use method 3) with a more sophisticated logic: check the protocol of current page before setting '_secure' parameter.
Hope, it helps.
I just did it the primitive way, sometimes it works best:
echo trim($_product->getProductUrl(),'http:')
Instead
$product->getProductUrl()
Try
$product->getUrlModel()->getUrl($product, array('_secure'=>(bool)Mage::app()->getStore()->isCurrentlySecure()))
This gives you a secure/unsecured product url based on your current protocol.
THere's an understated but important option in System | Configuration | Web ~ where you have to say "use secure url in frontend" -- if you set this to yes then a page loaded by https will use https links,
no need to write code or provide additional configuration in most cases

Resources