{"id":14822,"date":"2015-07-05T12:35:08","date_gmt":"2015-07-05T10:35:08","guid":{"rendered":"https:\/\/marabelia.com\/?p=14822"},"modified":"2025-06-20T12:46:55","modified_gmt":"2025-06-20T10:46:55","slug":"robots-txt-htaccess-gzip-compression-and-sitemaps-xml","status":"publish","type":"post","link":"https:\/\/marabelia.com\/en\/robots-txt-htaccess-gzip-compression-and-sitemaps-xml\/","title":{"rendered":"robots. txt, .htaccess, GZIP compression and sitemaps.xml"},"content":{"rendered":"<div class=\"wpb-content-wrapper\">[vc_row][vc_column][vc_column_text]\n<p style=\"text-align: justify;\">Integrating the <em>robots.txt, .htaccess<\/em> ( +GZIP compression )<em> and sitemaps.xml<\/em> files is a fundamental step for SEO optimization on our <em>WordPress<\/em> site. Below I explain in a simple way how to configure and add these files without much hassle.<\/p>\n<h6 style=\"text-align: justify;\"><span style=\"color: #000000;\"> \u25b6 <\/span> Creating XML Sitemaps<\/h6>\n<p style=\"text-align: justify;\">The <em>sitemap.xml<\/em> file is used to outline all existing pages of a website.<\/p>\n<p style=\"text-align: justify;\">Google designed this system to facilitate indexing and to directly send a summary of all the URLs on our site to Google&#8217;s indexing bot so that they can be indexed more easily and quickly.<\/p>\n<p style=\"text-align: justify;\">In Google\u2019s <em>support forum<\/em> they explain <a href=\"https:\/\/support.google.com\/webmasters\/answer\/183668?hl=es\" target=\"_blank\" rel=\"noopener\">how to create a sitemap<\/a> from scratch, but\u2026 <em>Why complicate things if there\u2019s a great plugin that solves it for us?<\/em><\/p>\n<p style=\"text-align: justify;\">The best option is undoubtedly to generate the sitemap automatically by installing the <a href=\"https:\/\/yoast.com\/wordpress\/plugins\/seo\/\" target=\"_blank\" rel=\"noopener\">SEO YOAST plugin.<\/a> Once the plugin is activated, our sitemap.xml will be available at ..\/sitemap_index.xml.<\/p>\n<p style=\"text-align: justify;\">To check it, click on your WordPress vertical menu \/ SEO -&gt; XML Sitemaps, then on the button \u201cYou can find your XML Sitemap here: XML Sitemap.\u201d If you get a <strong>404 Error Page Not Found<\/strong>, go back to the WordPress menu \/ Settings \/ Permalinks and simply save your permalinks again.<\/p>\n<p style=\"text-align: justify;\">If for some strange and unknown reason we don\u2019t want to install SEO Yoast, we can also generate the sitemap with <a href=\"https:\/\/wordpress.org\/plugins\/google-sitemap-generator\/\" target=\"_blank\" rel=\"noopener\">Google XML Sitemaps Generator<\/a>, and it will be automatically created in the root of our WordPress with the name <em>sitemap.xml<\/em>.<\/p>\n<p style=\"text-align: justify;\">It\u2019s that easy.<\/p>\n<h6 style=\"text-align: justify;\"><span style=\"color: #000000;\"> \u25b6 <\/span> Configuring the <em>robots.txt<\/em> file<\/h6>\n<p style=\"text-align: justify;\">The <em>robots.txt<\/em> file is a plain text file that provides recommendations for all search engine crawlers and robots to follow. This <a href=\"http:\/\/www.emezeta.com\/articulos\/robots-txt-todo-lo-que-deberia-saber\" target=\"_blank\" rel=\"noopener\">article<\/a> explains clearly and accurately what it is and how to configure it.<\/p>\n<p style=\"text-align: justify;\">To simplify things, here is the <em>robots.txt<\/em> file I usually use for <em>WordPress<\/em>:<\/p>\n<pre>Disallow: \/wp-admin\r\nDisallow: \/wp-includes\/\r\nDisallow: \/*\/feed\/\r\nDisallow: \/*\/trackback\/\r\nDisallow: \/*\/attachment\/\r\nDisallow: \/author\/\r\nDisallow: \/*\/feed\/\r\nDisallow: \/tag\/*\/page\/\r\nDisallow: \/tag\/*\/feed\/\r\nDisallow: \/xmlrpc.php\r\nDisallow: \/*?s=\r\nDisallow: \/*\/*\/*\/feed.xml\r\nDisallow: \/?attachment_id*\r\nSitemap: http:\/\/gooddesign.es\/sitemap.xml\r\n<\/pre>\n<p style=\"text-align: justify;\">You just need to copy this content into a plain text file, save it as <em>robots.txt<\/em>, and upload it to the root directory of your <em>WordPress<\/em> via FTP.<\/p>\n<p style=\"text-align: justify;\">If you don\u2019t want to use FTP, you can also generate the <em>robots.txt<\/em> with the <em>WP Robots Txt<\/em> plugin by <cite><a href=\"http:\/\/christopherdavis.me\">Christopher Davis<\/a><\/cite>.<\/p>\n<h6><span style=\"color: #000000;\">\u25b6 <\/span> <em>.htaccess<\/em> File (with <em>gzip<\/em> compression)<\/h6>\n<p style=\"text-align: justify;\">The <em>.htaccess<\/em> file is necessary for the proper functioning of WordPress. It is mainly used to specify security restrictions on the website: prevent directory listing, restrict access to specific files or folders, create custom error pages, prevent bandwidth theft, or block users or sites, among other options.<\/p>\n<p style=\"text-align: justify;\">From the <a href=\"https:\/\/codex.wordpress.org\/htaccess\" target=\"_blank\" rel=\"noopener\"><em>WordPress Codex<\/em><\/a> we get the basic <em>.htaccess<\/em> file for WordPress:<\/p>\n<pre># BEGIN WordPress\r\n&lt;IfModule mod_rewrite.c&gt;\r\nRewriteEngine On\r\nRewriteBase \/\r\nRewriteRule ^index\\.php$ - [L]\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . \/index.php [L]\r\n&lt;\/IfModule&gt;\r\n# END WordPress\r\n<\/pre>\n<p style=\"text-align: justify;\">Within this basic <em>.htaccess<\/em> file we can add the <em>GZIP compression<\/em> line. GZIP compression will make our website lighter in KB, which will lead to two major advantages: Bandwidth savings and increased website speed.<\/p>\n<pre>php_value output_handler ob_gzhandler<\/pre>\n<p style=\"text-align: justify;\">With the new GZIP line, the final <em>.htaccess<\/em> file would look like this:<\/p>\n<pre># BEGIN WordPress\r\n&lt;IfModule mod_rewrite.c&gt;\r\nRewriteEngine On\r\nRewriteBase \/\r\nRewriteRule ^index\\.php$ - [L]\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . \/index.php [L]\r\nphp_value output_handler ob_gzhandler\r\n# END WordPress\r\n<\/pre>\n<p style=\"text-align: justify;\">Now we can add the lines to tell it where our <em>robots.txt<\/em> and <em>sitemap.xml<\/em> files are located. So our <strong>FINAL GZIP FILE<\/strong> would look like this:<\/p>\n<pre># BEGIN WordPress\r\n&lt;IfModule mod_rewrite.c&gt;\r\nRewriteEngine On\r\nRewriteBase \/\r\nRewriteRule ^index\\.php$ - [L]\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . \/index.php [L]\r\nphp_value output_handler ob_gzhandler\r\n# END WordPress\r\n\r\n# canonical robots.txt\r\n&lt;IfModule mod_rewrite.c&gt;\r\nRewriteBase \/\r\nRewriteCond %{REQUEST_URI} !^\/robots.txt$ [NC]\r\nRewriteCond %{REQUEST_URI} robots.txt [NC]\r\nRewriteRule .* http:\/\/your-site.com\/robots.txt [R=301,L]\r\n&lt;\/IfModule&gt;\r\n\r\n# canonical sitemaps\r\n&lt;IfModule mod_alias.c&gt;\r\nRedirectMatch 301 \/sitemap\\.xml$ http:\/\/example.com\/sitemap.xml\r\nRedirectMatch 301 \/sitemap\\.xml\\.gz$ http:\/\/example.com\/sitemap.xml.gz\r\n&lt;\/IfModule&gt;\r\n<\/pre>\n<p style=\"text-align: justify;\">Copy this text into a plain text file, save it as <em>htaccess.txt<\/em> (without the dot), and upload it via FTP to the root folder of your <em>WordPress<\/em>. Once uploaded, rename it to <em>.htaccess<\/em> (with the dot and no extension). The next step is to make this file read-only to avoid major issues. This is done by editing the file permissions in your FTP client and changing them to 444.<\/p>\n<p style=\"text-align: justify;\">Everything should be working fine now, but let\u2019s make sure GZIP compression is actually enabled.<\/p>\n<p style=\"text-align: justify;\">At <a href=\"http:\/\/www.gidnetwork.com\/tools\/gzip-test.php\" target=\"_blank\" rel=\"noopener\"><em>GIDNETWORK TOOLS<\/em><\/a> we have a tool to test our compression. Just enter your URL.<\/p>\n<p class=\"entry-title\"><strong>You may also be interested in: <a href=\"https:\/\/marabelia.com\/en\/how-to-control-web-optimization-and-seo-wordpress-guide\/\" target=\"_blank\" rel=\"noopener\">Web Optimization and SEO Analysis in WordPress<\/a><\/strong><\/p>\n[\/vc_column_text][\/vc_column][\/vc_row]\n<\/div>","protected":false},"excerpt":{"rendered":"[vc_row][vc_column][vc_column_text] Integrating the robots.txt, .htaccess ( +GZIP compression ) and sitemaps.xml files is a fundamental step for SEO optimization on our WordPress site. Below I explain in a simple way how to configure and add these files without much hassle. \u25b6 Creating XML Sitemaps The sitemap.xml file is used to outline all existing pages of [&#8230;]\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[96,89,98],"tags":[],"class_list":["post-14822","post","type-post","status-publish","format-standard","hentry","category-seo","category-web-optimization","category-wordpress-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>robots. txt, .htaccess, GZIP compression and sitemaps.xml &#8226; Marabelia | Agencia Digital en Valencia<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/marabelia.com\/en\/robots-txt-htaccess-gzip-compression-and-sitemaps-xml\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"robots. txt, .htaccess, GZIP compression and sitemaps.xml &#8226; Marabelia | Agencia Digital en Valencia\" \/>\n<meta property=\"og:description\" content=\"[vc_row][vc_column][vc_column_text] Integrating the robots.txt, .htaccess ( +GZIP compression ) and sitemaps.xml files is a fundamental step for SEO optimization on our WordPress site. Below I explain in a simple way how to configure and add these files without much hassle. \u25b6 Creating XML Sitemaps The sitemap.xml file is used to outline all existing pages of [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/marabelia.com\/en\/robots-txt-htaccess-gzip-compression-and-sitemaps-xml\/\" \/>\n<meta property=\"og:site_name\" content=\"Marabelia | Agencia Digital en Valencia\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-05T10:35:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-20T10:46:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/marabelia.com\/wp-content\/uploads\/2025\/09\/Portada-Marabelia-sitio-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin-mbl\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-mbl\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"robots. txt, .htaccess, GZIP compression and sitemaps.xml &#8226; Marabelia | Agencia Digital en Valencia","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/marabelia.com\/en\/robots-txt-htaccess-gzip-compression-and-sitemaps-xml\/","og_locale":"en_US","og_type":"article","og_title":"robots. txt, .htaccess, GZIP compression and sitemaps.xml &#8226; Marabelia | Agencia Digital en Valencia","og_description":"[vc_row][vc_column][vc_column_text] Integrating the robots.txt, .htaccess ( +GZIP compression ) and sitemaps.xml files is a fundamental step for SEO optimization on our WordPress site. Below I explain in a simple way how to configure and add these files without much hassle. \u25b6 Creating XML Sitemaps The sitemap.xml file is used to outline all existing pages of [...]","og_url":"https:\/\/marabelia.com\/en\/robots-txt-htaccess-gzip-compression-and-sitemaps-xml\/","og_site_name":"Marabelia | Agencia Digital en Valencia","article_published_time":"2015-07-05T10:35:08+00:00","article_modified_time":"2025-06-20T10:46:55+00:00","og_image":[{"width":800,"height":800,"url":"https:\/\/marabelia.com\/wp-content\/uploads\/2025\/09\/Portada-Marabelia-sitio-1.jpg","type":"image\/jpeg"}],"author":"admin-mbl","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin-mbl","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[]}},"_links":{"self":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts\/14822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/comments?post=14822"}],"version-history":[{"count":2,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts\/14822\/revisions"}],"predecessor-version":[{"id":14891,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts\/14822\/revisions\/14891"}],"wp:attachment":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/media?parent=14822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/categories?post=14822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/tags?post=14822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}