How Do You Get The Store Secure URL in Magento? - forms

I have a form in Magento that is displayed over the insecure URL (http) but I need it to submit to the secure URL (https).
I display the URL I currently use the following code:
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
I am assuming I need to change the URL_TYPE_WEB to something else. Does anyone know what that something else is?

Have you tried this?
Mage::getUrl('',array('_secure'=>true))
I think that gets you the base secure url, I believe.
Mage::getUrl('customer/account/login',array('_secure'=>true))
Will get you to the login page. In other words,
Mage::getUrl('module/controller/action',array('_secure'=>true))
Will get you to any page you want, just substitute 'module/controller/action' for the appropriate combo.
Edit -- Fixed Typos

http://blog.geekslikeshinythings.com/2014/12/magento-force-secure-urls-https-on-all.html
this works in Mageno 1.9.1
use your app/etc/config.xml file
<?xml version="1.0"?>
<config>
<frontend>
<secure_url>
<all>/</all>
</secure_url>
</frontend>
</config>
If user is using https, this should force all urls to rewrite (created as) to https.

Use:
Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);
to read the the configuration value inside magento that has been set inside admin.

this worked to me
echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
For example:
if you browsing with http then
echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// http://dominio.com/customer/account/loginPost
if you browsing with https then
echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// https://dominio.com/customer/account/loginPost

You can do this in code and also from xml.
For example, if you want to set https for the check out page then you have to add the below code in your custom config.xml:
<code>
<secure_url>
<checkout_onepage>/checkout/onepage</checkout_onepage>
<checkout_multishipping>/checkout/multishipping</checkout_multishipping>
</secure_url>
</code>
Magento has a default feature for https for check out so you can do the same thing for other pages like for the customer page:
<code>
<secure_url>
<customer>/customer/</customer>
</secure_url>
</code>
I hope it'll help you.

Tried this its working for me.
Mage::getUrl('',array('_secure'=>true))
After added this code finally its look like below
IWD.ProductVideoView.urlGetVideo = "<?php echo Mage::getUrl('iwd_productvideo/player/getvideo/',array('_secure'=>true)); ?>?isAjax=true";

Related

Unable to use Liferay Freindly URL Mapper

I was following this document from Liferay Website to work Map Firendly URL Mappings
http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/adding-friendly-url-mapping-to-the-portlet
I am using Liferay version=6.1.0
During HyperLink navigation , i was getting the following url
http://localhost:8080/web/guest/what-we-do?p_p_id=sai_WAR_Saiportlet&
p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1
&_sai_WAR_Saiportlet_jspPage=%2Fhtml%2Fsai%2Fedit.jsp
To modify the above i have tried to use Friendly URL Mapper and i have done the following way
Inside liferay-portlet.xml file .
<portlet>
<portlet-name>sai</portlet-name>
<icon>/icon.png</icon>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>sai</friendly-url-mapping>
<friendly-url-routes>com/test/sai-friendly-url-routes.xml</friendly-url-routes>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>sai-portlet</css-class-wrapper>
</portlet>
Created a new file by name sai-friendly-url-routes.xml inside
D:\liferay-plugins-sdk-6.1.0-SNAPSHOT\portlets\Sai-portlet\docroot\WEB-INF\src\com\test\sai-friendly-url-routes.xml
The content inside sai-friendly-url-routes.xml is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.1.0//EN" "http://www.liferay.com/dtd/liferay-friendly-url-routes_6_1_0.dtd">
<routes>
<route>
<pattern>/{mvcPathName}</pattern>
<generated-parameter name="mvcPath">/{mvcPathName}.jsp</generated-parameter>
</route>
</routes>
But i observed there is no change in the url
http://localhost:8080/web/guest/what-we-do?p_p_id=sai_WAR_Saiportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_sai_WAR_Saiportlet_jspPage=%2Fhtml%2Fsai%2Fedit.jsp
Please let me know where exactly i am doing mistake .
You leave the values as they are. That is, you leave {mvcPathName} and "mvcPath" as-is.
When the friendly URL is generated, it parses mvcPath (i.e., edit.jsp or view.jsp) from the URL and then the pattern is applied, replacing .../edit.jsp with .../edit.
This example works for the edit JSP. And it works for the view page; but NOT when clicking Save ... which is something I could look into. However, if you go to edit and then click the back link, the friendly URL will show for the view JSP.
I've created a ticket to complete this example so that it also goes to a friendly URL when clicking save. I'll update this section when we've made the fix.
Thanks.

"Website: Not a valid URL format" when creating an application of twitter

I'd like to create an application that can integrate with Twitter.
So I went to the website: https://dev.twitter.com/apps/new to create an application.
But the WebSite: field always failed. It said that "Website: Not a valid URL format".
I tried different "valid" URLs, but failed.
Do you have any ideas on the twitter application?
Thanks in advance.
Michael
I was trying to set localhost URL and got the same error message.
After replacing
http://localhost
http://localhost/twitter/callback
with
http://127.0.0.1
http://127.0.0.1/twitter/callback
it let me saved my test application
Mine is working. Save it in this format http://url.com. Even this domain.com works.
You can try doing it in a different browser, logout and login.
In my case the problem was in trailing whitespace from copy/paste.
One easy mistake to make is both the callback url and website need to start with http://
This worked for me:
WebSite: http://example.com
CallbackURL: http://example.com/auth/twitter/callback/
I'm able to make applications if I include "http://" at the beginning. Also it might be something browser related (I'm using Chrome) so check that.
I was having the same Issue, then after googling, someone said that:
"I think your website and callback should match. Some examples:
website: http://www.quoteicon.com
callback: http://www.quoteicon.com/twitter/callback "
summarizing the field callback has to be prefixed with the website, otherwise it gets error that the URL is invalid!
and they dont accept local IPs to the webSite fields.
It worked for me, hope this help you.
Old question but I ran into this today. Twitter does not allow localhost or IP addresses in the URL (plus it does require http:// or https:// as a prefix).
However this doesn't help with local debugging.
So an easy workaround is to add something like myapp.here.com in your /etc/hosts file
127.0.0.1 myapp.here.com
and then enter http://myapp.here.com and http://myapp.here.com/auth/twitter in the fields.
That should allow local debugging. It is odd as Facebook makes this a bit easier and it seems like a common task for debugging these types of integrations.
You could even override your actual domain locally if you wanted to use the same Twitter App ID.
Be aware of localhost, if you are developing on local machine. Twitter doesn't allow url with http://localhost:3000 or without http.
I'm wonder, why ;] Hope, They will add it.
I just found that I didn't have a problem with my callback url at all, but the error message was for the Website url!
Tried everything now, eventually only https://example.com/auth worked.
I simply added www and the error was gone.
Previously
http://twitter.com/...
After
http://www.twitter.com/...
This issue is resolved when I give my Website & Callback URL same htt://URL.Hope it will help to resolve your solution.

IE and Facebook signed request

For some odd reason, i do not receive a "signed_request" when using IE. If i use the same application in firefox/chrome i get the signed request! has anyone had this problem and is there a solution.
I tried to search it up, but i can never get anything close to what i am asking (signed_request usually just takes over search and i get a bunch of documentation on how to parse it).
So i decided, well this is strange!
<?php print_r($_POST) // or request ?>
I made this as a page. In FF and Chrome, both give me the post information, but IE does not give me anything... just
Array( )
Thanks!
signed request is the included for case where user access your content via facebook. That should be signed to the server... and therefore it should not depends on the client browser. check you code to see if you have done something like redirecting the request when the session / user is invalid.
A solution that worked for me was to put this header in my tab page:
<?php
header('P3P: CP="CAO PSA OUR"');
header('P3P: CP="HONK"');
?>
I've found this solution here: http://hasin.me/2011/09/30/story-about-blue-e-iframed-web-application-wastage-of-6-hours-and/

Codeigniter Facebook app POST method AND query_string

I have a toy facebook app I'm playing with so I can understand how it all works. It's fine if you go the the app like this: http://apps.facebook.com/pushup-challenge/ (and connect it). But if you then go to it from your facebook page, FB uses the URL http://apps.facebook.com/pushup-challenge/?ref=bookmarks.
In my log file, I see that FB is POSTing the data and including the /?ref=bookmarks to it's call to my codeigniter system. This is causing it to either say "invalid URI parameters" or give me a 404, depending on if I've edited the system/core/URI.php file to add rawurlencode() to a particular call.
I've tried using mod_rewrite to get rid of the query_string, too, but since it's POSTing, it doesn't appear to be working (though I'm not exactly sure why).
Has anyone else run into this? How did you fix it?
Thanks in advance,
Hans
try $config['uri_protocol'] = “PATH_INFO”; and set enable_query_strings = TRUE
or
set
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=';
in config.php
Because it isn't calling your file by name (just ?ref=bookmarks) the server runs thru the standard default files: index.htm, index.html, index.asp. Because you need to accept a POST, you need a server that allows POSTs to htm & html if you choose to use those. Index.asp will accept POSTs on most servers, and that works for me.
SOLUTION: Add a file (index.asp), that calls the real app that you named in the App settings.

Bookmarked page redirect

I recently converted a site from asp to CF. Unfortunately, alot of the old users had the "homepage" bookmarked. www.example.com/homepage.asp
Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?
I would normally just delete those files, but the owner(s) wanted to keep it around for their own comparison reasons.
Any ideas?
Thanks
Put this in the old homepage.asp
<%# Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/index.cfm"
%>
If you don't want run an onerous asp file at all on the new site, you can do a custom 404 on the web server. If you point the 404 page to a .cfm file, you can extract all the various features from the request by including:
<!--- parse out the text in the URL parameters into an array --->
<cfset variables.requestparams = listtoarray(cgi.query_string,'/?&')>
<!--- get rid of the first 2 items in the array since they dont represent request info --->
<cfset foo = arraydeleteat(variables.requestparams,1)>
<cfset foo = arraydeleteat(variables.requestparams,1)>
You'll be left with an array representing the parameters that were passed in the original request. You can follow up on this by doing whatever analysis you need to on the url components to map it against the analogous pages in your CF site.
I'm surprised nobody has mentioned URL Rewriting. You can use mod_rewrite on *nix/apache, or ISAPI Rewrite or Ionics ISAPI Rewrite on Windows/IIS. I prefer Ionics if I'm on IIS.
The best bet is to do either a meta refresh in the actual homepage.asp page, it is quick and dirty, but works.
A better solution would be to have the .asp page do a 301 redirect to the new homepage, that way when search engines access the page as well they know it has moved.
What I do on Linux machines when I run into something like this is to create a symbolic link (ln -s /path/to/source /path/to/target).
Not sure what the Windows equivalent would be, so going with #Patrick's answer is probably best.
EDIT - The NTFS way of making a symlink:
http://en.wikipedia.org/wiki/NTFS_symbolic_link
see also http://en.wikipedia.org/wiki/Symbolic_link