VirtueMart Forum

VirtueMart 2 + 3 + 4 => 3rd party extension => Topic started by: PRO on June 05, 2012, 21:15:03 PM

Title: Back to HTTP Redirect Plugin
Post by: PRO on June 05, 2012, 21:15:03 PM
This plugin will redirect product details & category pages back to HTTP if your are in https.

J2.5++ ONLY
Download Here

http://www.kaizenmediaworks.com/virtuemart-2-0-redirect-back-to-http-plugin

GUYS: the plugin is having a problem when using SEF urls.

To redirect back to http

You can place this code in your category and product details template

UPDATED:::::: The search module was not working when you searched from an HTTPS page.


/* Back to http */
if (JRequest::getVar('search')!='true'){
$uri = & JFactory::getURI();
   $currentcheck=JURI::current();
         $comparethis = str_replace( 'https:', 'http:', $currentcheck );
      if ($comparethis !== $currentcheck){
       $app = JFactory::getApplication();
$app->redirect($comparethis, null, null, true, true);
       }   
       }
Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on June 15, 2012, 14:45:11 PM
guys has anyone tested this?

is it working? with and without SEF?
Title: Re: Back to HTTP Redirect Plugin
Post by: Dokho on June 18, 2012, 23:47:35 PM

It works without SFE. 

Thanks, I was looking a urgent solution.
Title: Re: Back to HTTP Redirect Plugin
Post by: Stonedfury on April 22, 2013, 22:18:23 PM
can we check to see if the site is loading the cart and if not then redirect all to http?
if the link = index.php?option=com_virtuemart&view=cart then https if not then http

I ask because as it is the code would work on pages it is inserted but what if used in main index.php of template. Would it override the one that switches to https? I have code in place that puts the cart into https regardless of any settings.

on default cart page /template/mytemplate/html/com_virtuemart/cart/default.php
   $currentcheck = JURI::current();
         $comparethis = str_replace( 'http:', 'https:', $currentcheck );
      if ($comparethis !== $currentcheck){
       $app = JFactory::getApplication();
$app->redirect($comparethis, null, null, true, true);
       }
Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on April 22, 2013, 22:30:05 PM
I do this with cart & user pages.
To make sure its ssl, to pass PCI testing



<?php
// make sure its HTTPS
$uri = & JFactory::getURI();
   $currentcheck=JURI::current();
         $comparethis = str_replace( 'http:', 'https:', $currentcheck );
      if ($comparethis !== $currentcheck){
       $app = JFactory::getApplication();
$app->redirect($comparethis, null, null, true, true);
       }
       ?>
Title: Re: Back to HTTP Redirect Plugin
Post by: Stonedfury on April 23, 2013, 17:39:59 PM
I downloaded the plugin and turned it on. I did not get any errors but it did not change the http to https. However I was wondering. You are doing a check to see what the view is. Can that be adjusted to check the links? Say for address, billing, cart, etc.,?
Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on April 23, 2013, 18:08:00 PM
the plugin will not work with sef urls.

just use the code I posted in whatever template you want it in.

Title: Re: Back to HTTP Redirect Plugin
Post by: tmdonovan on June 10, 2013, 15:44:34 PM
Hi, it seems like a lot of people have run into the problem of non-secure pages being set to HTTPS after visiting the first secure pages.  I appreciate that you wrote this plugin but it seems to be that this is a bug in VM2 and should be handled as such.  In addition, a plugin that doesn't work with SEF is not something I or others can use in a production site: first, we have a lot of internal links built with SEF URLs, and second, my client will not accept non-SEF URLs in a live site.  Is there any way to get this fixed as part of VM2 where it will work under all circumstances?  This is very important.
Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on June 10, 2013, 15:52:24 PM
I use these codes in my templates that i want to force either ssl or non ssl


Force NON ssl

<?php
/* Back to http */
   $currentcheck = JURI::current();
         $comparethis = str_replace( 'https:', 'http:', $currentcheck );
      if ($comparethis !== $currentcheck){
       $app = JFactory::getApplication();
$app->redirect($comparethis, null, null, true, true);
       }   
?>



Force SSL on pages


<?php
// make sure its HTTPS
$uri = & JFactory::getURI();
   $currentcheck=JURI::current();
         $comparethis = str_replace( 'http:', 'https:', $currentcheck );
      if ($comparethis !== $currentcheck){
       $app = JFactory::getApplication();
$app->redirect($comparethis, null, null, true, true);
       }
       ?>

Title: Re: Back to HTTP Redirect Plugin
Post by: tmdonovan on June 10, 2013, 15:54:11 PM
Where do I put this code?  And will this work with SEF?
Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on June 10, 2013, 19:19:13 PM
you put the code IN WHATEVER template you need it in

http://forum.virtuemart.net/index.php?topic=90935.0


for example

on cateogry & product page. I do "back to http"

on user page, & cart page, I do "force https"

Title: Re: Back to HTTP Redirect Plugin
Post by: tmdonovan on June 11, 2013, 16:40:09 PM
Thanks for your help these changes worked for me.  And I have SEF turned on and it is working perfectly.  Your forum entry about VM 2.0 templates helped so much.
Title: Re: Back to HTTP Redirect Plugin
Post by: RevoLion on June 11, 2013, 20:20:16 PM
Quote from: PRO on June 10, 2013, 19:19:13 PM
you put the code IN WHATEVER template you need it in

http://forum.virtuemart.net/index.php?topic=90935.0


for example

on cateogry & product page. I do "back to http"

on user page, & cart page, I do "force https"



Are these to go into the main template file for the site or VM template files? Sorry just trying to get to the solved issue.

Thanks,
Jeremy
Title: Re: Back to HTTP Redirect Plugin
Post by: tmdonovan on June 11, 2013, 20:22:57 PM
You want to override the joomla template.  Follow the instructions here - http://forum.virtuemart.net/index.php?topic=90935.0
Title: Re: Back to HTTP Redirect Plugin
Post by: RevoLion on June 11, 2013, 20:38:31 PM
Thank you tmdonovan,

Do I need to download a plugin or anything for this to take affect.


Jeremy
Title: Re: Back to HTTP Redirect Plugin
Post by: tmdonovan on June 11, 2013, 20:52:52 PM
I didn't use the Back to HTTP Redirect plugin described in the first post of this thread.  I am an experienced programmer, so I followed the instructions to manually override the joomla template, then modified the productdetails and category default.php files directly to handle the "back to HTTP" function, as described by PRO on June 10, 2013 at 11:19:13. 

The first post has the link to download the plugin, and I will have to defer to PRO's expertise with respect to its use.
Title: Re: Back to HTTP Redirect Plugin
Post by: RevoLion on June 11, 2013, 21:08:49 PM
I prefer programming, instead of plugin. Thank you so much for your clarity on this.

Jeremy
Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on June 11, 2013, 22:49:41 PM
the "plugin" will not work with SEF urls, BECAUSE   system plugins run BEFORE JRoute (which is what makes the urls)

SO:  when you put the code in  your VIRTUEMART template override files,it will work with SEF urls.

so for example

views/tmpl/productdetails/default.php

HERE.

BUT!

Do a template  override
http://forum.virtuemart.net/index.php?topic=90935.0

Title: Re: Back to HTTP Redirect Plugin
Post by: Stonedfury on June 11, 2013, 23:27:11 PM
Would it be possible to just do <?php 
$view 
JRequest::getVar('view'); // checks to see what view you are on EX: category
if ($view == 'TheViewYouwant') { 
/*check to see if https if not make https */
$currentcheck JURI::current();
$comparethis str_replace'http:''https:'$currentcheck );
if (
$comparethis !== $currentcheck){
$app JFactory::getApplication();
$app->redirect($comparethisnullnulltruetrue);

} else {

/* check if http and if not set to http */
$currentcheck JURI::current();
$comparethis str_replace'https:''http:'$currentcheck );
if (
$comparethis !== $currentcheck){
$app JFactory::getApplication();
$app->redirect($comparethisnullnulltruetrue);
}
}
?>

It does not really require anything other than the view. Possibly use or to add more views into the list? What you think Pro?

Title: Re: Back to HTTP Redirect Plugin
Post by: PRO on June 12, 2013, 01:35:22 AM
Quote from: Stonedfury on June 11, 2013, 23:27:11 PM
Would it be possible to just do <?php 
$view 
JRequest::getVar('view'); // checks to see what view you are on EX: category
if ($view == 'TheViewYouwant') { 
/*check to see if https if not make https */
$currentcheck JURI::current();
$comparethis str_replace'http:''https:'$currentcheck );
if (
$comparethis !== $currentcheck){
$app JFactory::getApplication();
$app->redirect($comparethisnullnulltruetrue);

} else {

/* check if http and if not set to http */
$currentcheck JURI::current();
$comparethis str_replace'https:''http:'$currentcheck );
if (
$comparethis !== $currentcheck){
$app JFactory::getApplication();
$app->redirect($comparethisnullnulltruetrue);
}
}
?>

It does not really require anything other than the view. Possibly use or to add more views into the list? What you think Pro?



where would you put this?

it cant be a plugin because system plugins dont know the "view" unless its actually in the url.

you could do something like this in your joomla template though if you want.

you can use the code however you want.

But I use mine just like I posted before,
I use it in specific templates etc. to->https   or back to->http

I also use it in my content templates



Title: Re: Back to HTTP Redirect Plugin
Post by: Stonedfury on June 12, 2013, 03:56:13 AM
Maybe the index.php. It was a thought.
Title: Re: Back to HTTP Redirect Plugin
Post by: volksman3 on October 29, 2013, 02:12:54 AM
Hi All,

Been having the SSL issues people have mentioned here and i found this worked for me http://extensions.joomla.org/extensions/site-management/url-redirection/11326 allows redirection to SSL and back to SSL for selected pages, works with SEF URLs and VM2.

Title: Re: Back to HTTP Redirect Plugin
Post by: trumples on October 30, 2013, 07:29:18 AM
This is a great plugin for redirects, thanks for coming across it.