Skip to content

Instantly share code, notes, and snippets.

View kaushalp's full-sized avatar

Kaushal Kumar Panday kaushalp

  • Microsoft
  • Redmond
View GitHub Profile
@kaushalp
kaushalp / .htaccess
Created November 3, 2017 16:40
Deny Specific IP Address
Order Allow,Deny
Deny from env=DenyAccess
Allow from all
SetENVIf X-Client-IP "xxx.xxx.xxx.xxx" DenyAccess
@kaushalp
kaushalp / .htaccess
Last active November 3, 2017 16:46
allow specific ipadress
Order Deny,Allow
Deny from all
SetENVIf X-Client-IP "xxx.xxx.xxx.xxx" AllowAccess
Allow from env=AllowAccess
@kaushalp
kaushalp / httpsRedirect.vb
Created May 8, 2017 14:34
HTTP to HTTPS Redirect using ASP
<%
If Request.ServerVariables("HTTPS") = "off" Then
Response.Redirect "https://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("UNENCODED_URL")
ElseIf Request.ServerVariables("HTTPS") = "on" Then
Response.Redirect "https://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("UNENCODED_URL")
End If
%>
@kaushalp
kaushalp / httpsRedirectRule.xml
Created May 8, 2017 14:26
URL Rewrite rule to redirect from HTTP to HTTPS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<?php
$connstr = getenv("MYSQLCONNSTR_MySqlDB");
//Parse the above environment variable to retrieve username, password and hostname.
foreach ($_SERVER as $key => $value)
{
if (strpos($key, "MYSQLCONNSTR_") !== 0)
{
continue;
}