Total Pageviews

Thursday, July 10, 2014

Redirect Non WWW to WWW using Rewrite module

Using Regex

<rewrite>
    <rules>
        <rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^yourdomain.com$" />
            </conditions>
            <action type="Redirect" url="http://www.yourdomain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>

Using Wildcards

<rewrite>
    <rules>
        <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="domain.com" />
            </conditions>
            <action type="Redirect" url="http://www.domain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>

Thursday, July 3, 2014

Redirecting HTTP page to HTTPS using Rewrite module


<rewrite>
            <rules>
                <rule name="Redirect to HTTPS" stopprocessing="true">
                    <match url=".*">
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$">
                        <add input="{HTTP_HOST}" pattern="^www\.yourdomain\.com$">
                        <add input="{HttpsRedirects:{REQUEST_URI}}" pattern="(.+)">
                    </add></add></add></conditions>
                    <action appendquerystring="false" redirecttype="SeeOther" type="Redirect" url="https://{HTTP_HOST}/{C:1}">
                </action></match></rule>
            </rules>
            <rewritemaps>
                <rewritemap name="HttpsRedirects">
                    <add key="/content_common/test.aspx?id=b1909882-22c1-4176-8012-9417c50b0276" value="/content_common/test.aspx?id=b1909882-22c1-4176-8012-9417c50b0276">
                 
                </add></rewritemap>
            </rewritemaps>
        </rewrite>

Wednesday, February 20, 2013

Reseeding a SQL Server Table

Indentity column will be reset to the value specified.

DBCC CHECKIDENT (tablename, RESEED, 5)

Sunday, January 20, 2013

Validating upload control for file extentions


Regular expression ="^.+(.doc|.DOC|.docx|.DOCX|.txt|.TXT|.pdf|.PDF)$"

Sunday, January 13, 2013

Finding column name on SQL Server database


SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%DocumentID%'
ORDER BY schema_name, table_name;