For a spesific page (order.php) I want if the user didn't entered https to automatically reload it with https (note that this page loads also other pages with includes based on a _GET variable-e.g order.php?stat= 1) and in all other pages to enforce http (all other pages loads with index.php in which I include all the others based on a _GET variable like above any suggestions?)
3 1367
After some digging I found this which works, (though I do not know if it will with nice URLS) -
function goElseWhere()
-
{
-
var url = document.URL;
-
-
if (url.indexOf("https")==-1)
-
{
-
//alert('den einai https');
-
-
}
-
else
-
{
-
//alert('einai https');
-
url=url.replace(/https/i,"http")
-
window.location = url;
-
-
}
-
-
}
-
goElseWhere();
-
Note that the script above enforce http if the user types https
acoder 16,027
Recognized Expert Moderator MVP
Why not use server-side code for this? If someone has JavaScript disabled, it will remain on HTTP only.
pronerd 392
Recognized Expert Contributor
It would be both easier and more reliable to do this with the server configuration. You would not have to write and code, and it would still work if the user had JavaScript disabled.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Groove |
last post by:
Hopefully, this isn't too dumb of a question. I have a asp.net (2) app
running on a dedicated Windows 2003 server. My host provider who manages
the machine purchased and "installed" the SSL certificate and took care of
all of the details (no experience on my part) to enabled SSL on our app. We
can now browse the site using HTTPS. The little lock in IE appears and it
seems to be encrypted.
How can I prevent any of the app/site being...
|
by: Jens Jensen |
last post by:
Hello gurus,
We have a site that need security upgrade to run over https.
We want people to be redirected to https:oursite when the type what the
know, http:oursite.
Is this possible?
How?
mnay thanks
JJ
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
I am trying to set this up using asp code and IIS configuration. But it
seems not working. Here it is the way I am doing.
In IIS I set up a virtual directory with secure communication, I checked
require secure channel, require 128-bit encryption. In custom error, instead
of using default message
HTTP 403.4 - Forbidden: SSL required
Internet Information Services
in iishelp 403.4htm, I am trying to do redirect automatically.
so I...
|
by: drewdall |
last post by:
Hello All,
I've read a lot of stuff which says it's impossible to hide Javascript, so if I get my PHP script to return some Javascript inside some XML using AJAX, how can it be viewed in the browser?
Obviously, some essential Javascript has to be there at the outset, ie. that which handles the AJAX, so you can't hide that, but if you then use AJAX to supply ad hoc Javascript on demand, can it be seen anywhere?
Your technical...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |