Saturday, 16 July 2022

Extracting Nupkg files using command line

Rename it to zip first then extract files as below


1.    Rename-Item -Path A_Package.nupkg -NewName A_Package.zip

2.    Make sure to replace "A_Package" with your package name.

3.    Expand-Archive -Path A_Package.zip -DestinationPath C:\Reference

Wednesday, 13 July 2022

SXA/Sitecore/.Net Rewrite Rules (Lower case, remove space for the URL)

.Net: Create the "RewriteRules.config" file and refer the file in "Web.config"

SXA/Sitecore: Create the "RewriteRules.config" file and refer the file in "Web.config" from CD environment.

Note: This will work as IIS rewrite module only

RewriteRules.config


<?xml version="1.0" encoding="utf-8"?>

  <rules>

  <!-- https://blog.coates.dk/2018/01/15/lower-casing-rewrite-rules-breaks-the-sitecore-client/ -->

  <!--This is used for XP SCALED-->

  <rule name="LowerCaseRule - not including querystring" stopProcessing="true">

    <match url="(.*)" />

    <conditions>

      <add input="{PATH_INFO}" pattern=".*[A-Z]" ignoreCase="false" />

      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

      <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />

      <add input="{REQUEST_URI}" pattern="^/(sitecore)" negate="true" />

      <add input="{REQUEST_URI}" pattern="^/(sitecore modules)" negate="true" />

      <add input="{REQUEST_URI}" pattern="^/-/" negate="true" />

      <add input="{REQUEST_URI}" pattern=".*(-/media).*" negate="true" />

      <add input="{REQUEST_URI}" pattern=".*(~/media).*" negate="true" />

      <add input="{REQUEST_URI}" pattern=".*(~/icon).*" negate="true" />

      <add input="{REQUEST_URI}" pattern="WebResource.axd" negate="true" />

      <add input="{REQUEST_URI}" pattern="ScriptResource.axd" negate="true" />

      <add input="{REQUEST_URI}" pattern="jsnlog.logger" negate="true" />

      <add input="{REQUEST_URI}" pattern="Telerik.Web.UI.WebResource.axd" negate="true" />

      <add input="{REQUEST_METHOD}" matchType="Pattern" pattern="POST" ignoreCase="true" negate="true" />

      <add input="{REQUEST_URI}" pattern="^/(identity)" negate="true" />

    </conditions>

    <action type="Redirect" url="https://{HTTP_HOST}/{ToLower:{R:1}}" appendQueryString="true" redirectType="Permanent" />

  </rule>

  <!--Added Sitecore OOTB rules here - So, XML Transforms work better and we manage all rewrite rules at single place-->

  <rule name="RemoveTrailingSlashRule1" stopProcessing="true">

    <match url="(.*)/$" />

    <conditions>

      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

    </conditions>

    <action type="Redirect" url="{R:1}" />

  </rule>

  <rule name="Block Sitecore Access Rule" stopProcessing="true">

    <match url=".*" />

    <conditions>

      <add input="{URL}" pattern="^/sitecore/?.*" />

      <add input="{URL}" pattern="^/sitecore/service/?.*" negate="true" />

      <add input="{URL}" pattern="^/(sitecore modules)" negate="true" />

    </conditions>

    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." />

  </rule>

  <rule name="Remove en-us" stopProcessing="true">

    <match url=".*(en-us)(.*)" />

    <action type="Redirect" url="https://{HTTP_HOST}{R:2}" appendQueryString="true" redirectType="Permanent" />

  </rule>

  <rule name="replace space with hyphen-5" stopProcessing="true">

    <match url="^(.*) (.*) (.*) (.*) (.*) (.*).*$" ignoreCase="false" />

    <conditions>

      <add input="{URL}" pattern="^/(sitecore modules)" negate="true" />

    </conditions>

    <action url="https://{HTTP_HOST}/{R:1}-{R:2}-{R:3}-{R:4}-{R:5}-{R:6}" type="Redirect" appendQueryString="true" redirectType="Permanent" />

  </rule>

  <rule name="replace space with hyphen-4" stopProcessing="true">

    <match url="^(.*) (.*) (.*) (.*) (.*).*$" ignoreCase="false" />

    <conditions>

      <add input="{URL}" pattern="^/(sitecore modules)" negate="true" />

    </conditions>

    <action url="https://{HTTP_HOST}/{R:1}-{R:2}-{R:3}-{R:4}-{R:5}" type="Redirect" appendQueryString="true" redirectType="Permanent" />

  </rule>

  <rule name="replace space with hyphen-3" stopProcessing="true">

    <match url="^(.*) (.*) (.*) (.*).*$" ignoreCase="false" />

    <conditions>

      <add input="{URL}" pattern="^/(sitecore modules)" negate="true" />

    </conditions>

    <action url="https://{HTTP_HOST}/{R:1}-{R:2}-{R:3}-{R:4}" type="Redirect" appendQueryString="true" redirectType="Permanent" />

  </rule>

  <rule name="replace space with hyphen-2" stopProcessing="true">

    <match url="^(.*) (.*) (.*).*$" ignoreCase="false" />

    <conditions>

      <add input="{URL}" pattern="^/(sitecore modules)" negate="true" />

    </conditions>

    <action url="https://{HTTP_HOST}/{R:1}-{R:2}-{R:3}" type="Redirect" appendQueryString="true" redirectType="Permanent" />

  </rule>

  <rule name="replace space with hyphen-1" stopProcessing="true">

    <match url="^(.*) (.*).*$" ignoreCase="false" />

    <conditions>

      <add input="{URL}" pattern="^/(sitecore modules)" negate="true" />

    </conditions>

    <action url="https://{HTTP_HOST}/{R:1}-{R:2}" type="Redirect" appendQueryString="true" redirectType="Permanent" />

  </rule>

</rules>



Web.config

<system.webServer>
<rewrite>
<rules configSource="RewriteRules.config"/>
</rewrite>  
</system.webServer>

Sunday, 26 June 2022

Upgrade Angular project to Latest version

After UpgradeBefore Upgrade

1.    Make sure you have upgraded node js to the LTS version and then follow the below.

2.    Go to your project folder and open the terminal and run the below commands:


>npm uninstall --save-dev angular/cli

>npm i -g npm-check-updates

>ncu -u

ERROR (if the below error occurs follow the below link to fix in node js config): 

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead


>npm install

>npm uninstall @angular-devkit/build-angular

>npm install --save-dev @angular-devkit/build-angular
 
>npm install --save --legacy-peer-deps

Sunday, 2 January 2022

Sitecore rich text field in page editor is not editable when it contains HTML formatting

This is a known issue when you put an editable rich text inside a <p> tag.

There are plenty of html tags which are not allowed inside a <p> tag. That why your browser closes <p> tag and break the functionality of editable rich text.

Remove <p> tag which is around the @Editable.

Extracting Nupkg files using command line

Rename it to zip first then extract files as below 1.     Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2.     Make sure to repla...