TECHIES WORLD

For Techs.... Techniques.... Technologies....

ApacheCpanelLinuxPHP

How to exclude sitemap.xml and robots.txt from https redirection

A sitemap is a file where you provide information about the pages, videos, and other files on your site, and the relationships between them

A robots.txt file tells search engine crawlers which pages or files the crawler can or can't request from your site.

This article explains the way to exclude sitemap.xml and robots.txt from https redirection using .htaccess.

To achieve this, add the following lines to the .htaccess file in the root folder of the website.

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} !/(robots.txt|sitemap.xml)\s [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,NE,R=302]

That's all...

Leave a Reply