{"id":19354,"date":"2022-08-30T21:01:03","date_gmt":"2022-08-30T13:01:03","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=19354"},"modified":"2023-03-31T19:02:28","modified_gmt":"2023-03-31T11:02:28","slug":"guide-to-htaccess","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/","title":{"rendered":"A Beginner&#8217;s Guide to .htaccess for Designers and Developers"},"content":{"rendered":"<p>Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can <strong>quickly reset document types, parsing engines, URL redirects<\/strong>, and many other crucial features.<\/p>\n<p>Designers or developers who are not very technical may not get into the specifics of managing their own .htaccess file. But the topic itself is fascinating and worth some investigation.<\/p>\n<p>For this article, I want to present some more purposeful concepts for designers and developers. Anybody who is <strong>launching their own website on an Apache server<\/strong> will want to understand how to manage their .htaccess file. It <strong>provides so much customizability<\/strong> and it <strong>can work across pretty much any web programming languages<\/strong>.<\/p>\n<p>At the bottom of this post I have added some external web apps to <strong>help newcomers generate their .htaccess files dynamically<\/strong>.<\/p>\n<h2>Why use an .htaccess File?<\/h2>\n<p>This is a great question and perhaps we should start by answering \u201c<em>what is a .htaccess file<\/em>\u201c?<\/p>\n<p>.htaccess is a very special configuration file used by the Apache web server. They can tell the web server <strong>how to present various forms of information and how to handle various HTTP request headers.<\/strong><\/p>\n<p>Really it is a means of <strong>decentralization<\/strong> to organize web server settings. One physical server may hold 50 different websites, each with its own .htaccess file. It grants a lot of power to webmasters, which would otherwise be impossible.<\/p>\n<p>But why should you use one?<\/p>\n<p><strong>The biggest reason is security.<\/strong><\/p>\n<p>You can <strong>lock out certain directories or make them password protected<\/strong>. This is great for private projects or new <abbr title=\"Content Management System\">CMS<\/abbr> (Content Management Systems) where you want a little extra security. But there are also common tasks like redirecting 404 error messages to a certain webpage.<\/p>\n<p><strong>This only takes a single line of code<\/strong>, and it can dramatically impact how visitors react to missing pages.<\/p>\n<p>Truthfully, there is not much I can say to convince others that a .htaccess file is worth understanding. Once you see it in action, then you can recognize all of the value which comes from this tiny config file.<\/p>\n<p>Also, I hope the rest of this article may present some insightful topics to bring webmasters into the light of managing a .htaccess configuration.<\/p>\n<h2>Allow\/Deny Access<\/h2>\n<p><strong>It is possible to recognize potential spam visitors and deny them access to your website.<\/strong> This can be a little extreme. However, if you know that a person or group of people have been targeting your website, there are some options to choose from.<\/p>\n<p>You could pick a domain referral to deny or ban visitors by IP address.<\/p>\n<pre>order allow,deny\r\ndeny from 255.0.0.0\r\ndeny from 123.45.6.\r\nallow from all<\/pre>\n<p>Notice the 2nd IP address is missing the 4th integer. <strong>This code block will target the first IP(255.0.0.0) and every IP within the range of 123.45.6.0-255,<\/strong> then allow all other traffic.<\/p>\n<h2>Prevent Directory Listing<\/h2>\n<p>There will be times when you have an open directory that is <strong>set up to allow browsing by default.<\/strong> This means users can view all the files listed inside an internal directory structure, like your images folder.<\/p>\n<p>Some developers do not want to allow directory listing, and thankfully, the code snippet is pretty easy to remember.<\/p>\n<pre>Options -Indexes\r\n<\/pre>\n<p>I have seen this answer presented countless times throughout <a target=\"_blank\" href=\"https:\/\/stackoverflow.com\/\/questions\/2530372\/how-do-i-disable-directory-browsing\" rel=\"noopener nofollow\">Stack Overflow<\/a> and it may be one of the easiest .htaccess rules to remember.<\/p>\n<p>It is possible to actually <strong>create multiple .htaccess files inside each of these directories<\/strong>, so maybe one of them is password protected, but the others are not. And you can still keep the <code>Options -Indexes<\/code> so that visitors cannot browse through your website \/images\/ folder.<\/p>\n<h2>Password Protection<\/h2>\n<p>Password-protecting your directories is a very common procedure for <strong>securing administration areas and other folders crucial to your website<\/strong>. Sometimes you only want to offer access to a small group of people.<\/p>\n<p>Other times, passwords prevent hackers from gaining access to your website administration panel. But either way, it is a very powerful solution to a whole number of problems.<\/p>\n<p>To do so, we can add the rule below:<\/p>\n<pre>AuthType Basic\r\nAuthName \"This Area is Password Protected\"\r\nAuthUserFile \/full\/path\/to\/.htpasswd\r\nRequire valid-user\r\n<\/pre>\n<p>Notice that we need to provide a file named <code>.htpasswd<\/code>. This file should contain the username and the hashed password to allow access. Fortunately, you can simply use <a href=\"http:\/\/aspirine.org\/htpasswd_en.html\">an external tool<\/a> that allows you to generate it easily.<\/p>\n<h3>Security for WordPress<\/h3>\n<p>To put this password-protection idea to good use, let\u2019s display a real-world example. This more complicated code snippet will <strong>force user authentication <\/strong>for anybody accessing the WordPress\u2019 <em>wp-login.php<\/em> file.<\/p>\n<p>You will find the original source on <a target=\"_blank\" href=\"https:\/\/www.askapache.com\/htaccess\/\" rel=\"noopener\">Ask Apache<\/a> which has numerous other WordPress protection snippets.<\/p>\n<pre>&lt;Files wp-login.php&gt;\r\nOrder Deny,Allow\r\nDeny from All\r\nSatisfy Any\r\nAuthName \"Protected By AskApache\"\r\nAuthUserFile \/web\/askapache.com\/.htpasswda1\r\nAuthType Basic\r\nRequire valid-user\r\n&lt;\/Files&gt;\r\n<\/pre>\n<p>And if you are going to follow these .htaccess rules, it might also help to password-protect the admin area. Typically the <em>wp-login.php<\/em> file is going to get the most hits from people attempting to brute force their way into your system.<\/p>\n<p>So even just the sample codes above would be <strong>more than enough added security<\/strong> for your WordPress website.<\/p>\n<h2>HTTP\/HTTPS URL Rewrite Rules<\/h2>\n<p>Rewriting URLs is probably one of the most common uses for .htaccess files. WordPress default installations can actually <strong>generate an .htaccess file right from the administration panel<\/strong>. This allows you to create pretty URLs which do not have the <code>.php?p=1<\/code> structure.<\/p>\n<p>I want to look at <a target=\"_blank\" href=\"https:\/\/www.askapache.com\/htaccess\/modrewrite-tips-tricks\/\" rel=\"noopener\">this rewrite example<\/a> on <strong>how to update underscores to dashes<\/strong> since it <strong>contains a lot of the most important elements<\/strong>.<\/p>\n<p><code>RewriteEngine<\/code> and <code>RewriteBase<\/code> can almost always be set to these exact values. But you need the <code>RewriteEngine<\/code> turned on for anything else to work.<\/p>\n<p>There are <a target=\"_blank\" href=\"https:\/\/stackoverflow.com\/\/questions\/869092\/how-to-enable-mod-rewrite-for-apache-2-2\" rel=\"noopener nofollow\">plenty of guides online<\/a> explaining how to enable <code>mod_rewrite<\/code> and your hosting provider can also help.<\/p>\n<p>Notice the syntax follows a pattern of <code>RewriteRules<\/code> at the top. These rules are used to <strong>match against cases that are being sent as an HTTPS request<\/strong>. These are answered by a <code>RewriteRule<\/code> which in this case redirects everything to the domain <em>d.com<\/em>.<\/p>\n<p>The ending brackets like <code>[R=301,L]<\/code> are called <a target=\"_blank\" href=\"https:\/\/httpd.apache.org\/docs\/2.2\/rewrite\/flags.html\" rel=\"noopener\">rewrite flags<\/a> which are important, but more of an advanced topic.<\/p>\n<pre>Options +FollowSymLinks\r\nRewriteEngine On\r\nRewriteBase \/\r\n \r\nRewriteRule !\\.(html|php)$ - [S=4]\r\nRewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]\r\nRewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]\r\nRewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]\r\nRewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]\r\n \r\nRewriteCond %{ENV:uscor} ^Yes$\r\nRewriteRule (.*) https:\/\/d.com\/$1 [R=301,L]\r\n<\/pre>\n<p class=\"note\">If you want to delve a bit deeper you can find a long list of flags on <a target=\"_blank\" href=\"https:\/\/www.askapache.com\/htaccess\/mod_rewrite-variables-cheatsheet\/\" rel=\"noopener\">this cheatsheet webpage<\/a>.<\/p>\n<p>The <code>mod_rewrite<\/code> syntax is definitely a little confusing but don\u2019t be intimidated! The snippets can look a lot easier in other examples.<\/p>\n<p>When just getting started, I have to recommend <a target=\"_blank\" href=\"https:\/\/www.generateit.net\/mod-rewrite\/\" rel=\"noopener\">this mod_rewrite webapp<\/a> that helps you generate code samples using real URLs.<\/p>\n<p>This is a brilliant tool because you can look up various items in the syntax to see what they actually do in the Rewrite rules.<\/p>\n<p>But don\u2019t try to overload yourself on these all at once. It took me well over 3-4 months to really start understanding how to rewrite URLs with [0-9a-zA-Z]+ and similar patterns. Keep on practicing, and in time, I promise you will get this stuff like it\u2019s common-sense knowledge.<\/p>\n<h2>Code Snippets for developers<\/h2>\n<p>I love easy-to-use snippets, and I want to put together this small collection of pertinent .htaccess codes for developers<\/p>\n<p>Each of these ideas can fit nicely into your own .htaccess file along with other code blocks. Most of these snippets are great for <strong>solving quick problems or fixes in your web server environment<\/strong>.<\/p>\n<p>Imagine the perfect Apache setup for brand new webmasters just getting started online.<\/p>\n<h3>Setting <code>DirectoryIndex<\/code><\/h3>\n<p>You can tell Apache which documents should be initially treated as the \u201cmain\u201d document with <code>DirectoryIndex<\/code>. Typically you\u2019d want to target an <code>index<\/code>-named files <strong>such as index.html and index.php<\/strong>.<\/p>\n<pre>DirectoryIndex index.html index.php<\/pre>\n<p>The order of documents should start with the most important and move through the ranks to the least important. In the example above, if we do not have an HTML, then the fallback will go to <strong>index.php<\/strong>. And you could even name these files <strong>home.php<\/strong> or <strong>someotherfile.php<\/strong> and it is all valid syntax.<\/p>\n<h3>Force \"www\" or \"non-www\" subdomain<\/h3>\n<p>Google can work with both versions of your website domain if you do not specify <em>www.domain.com<\/em> or just <em>domain.com<\/em>. In my experience, it is best practice to <strong>choose one of these and set it as the only choice<\/strong> via .htaccess.<\/p>\n<p>Then Google will not index various URLs, with some pointing to the WWW subdomain while others do not.<\/p>\n<pre># Force WWW Subdomain\r\nRewriteEngine On\r\nRewriteCond %{HTTP_HOST} ^domain.com [NC]\r\nRewriteRule ^(.*)$ https:\/\/www.domain.com\/$1 [L,R=301]\r\n\r\n# No Subdomain\r\nRewriteEngine On\r\nRewriteCond %{HTTP_HOST} !^domain.com$ [NC]\r\nRewriteRule ^(.*)$ https:\/\/domain.com\/$1 [L,R=301]\r\n<\/pre>\n<p>This code snippet comes from a <a target=\"_blank\" href=\"https:\/\/css-tricks.com\/snippets\/htaccess\/www-no-www\/\" rel=\"noopener\">CSS-Tricks archive<\/a> and provides a very handy solution.<\/p>\n<p>You should update the domain to be whatever you need for your own website. Otherwise, there will be problems, and you\u2019ll notice right away! But I do highly support forcing one of these two options and it is at the top of my tasks list after launching a new website.<\/p>\n<h3>Force Media File Downloads<\/h3>\n<p>Another fairly important snippet allows forcing certain media types to <strong>download instead of being displayed in the browser<\/strong>.<\/p>\n<p>Immediately, I can think of PDF documents and MP3 audio files which may be presented in a downloadable format, but here is how you can force them <strong>to download<\/strong>?<\/p>\n<pre>AddType application\/octet-stream .zip .mp3 .mp4\r\n<\/pre>\n<p>Feel free to include even more file types at the end of this line. All of the media formats using the octet-stream MIME type will be downloadable. Forcing this through .htaccess is a very direct route to ensure people are not able to view these files in the browser.<\/p>\n<h3>Custom Error Documents<\/h3>\n<p>One last final piece I want to add is a full template of <a target=\"_blank\" href=\"https:\/\/www.askapache.com\/htaccess\/#Custom_ErrorDocuments\" rel=\"noopener\">custom error documents<\/a>. Usually these number codes are only seen on the server end. But there are plenty of these error documents which you should be familiar with.<\/p>\n<p>A few examples might be <strong>403\/404 errors <\/strong>and the<strong> 301 redirect<\/strong>.<\/p>\n<p>This error code template <strong>starts at 100 and moves upwards into 500 errors<\/strong>. Please note that you obviously do not need all of these. Only the most common errors would be necessary, and possibly a few obscure snippets if you feel the need.<\/p>\n<p>If you do not recognize a code just <a target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_HTTP_status_codes\" rel=\"noopener\">look it up on Wikipedia<\/a> to get a better understanding.<\/p>\n<pre>ErrorDocument 100 \/100_CONTINUE\r\nErrorDocument 101 \/101_SWITCHING_PROTOCOLS\r\nErrorDocument 102 \/102_PROCESSING\r\nErrorDocument 200 \/200_OK\r\nErrorDocument 201 \/201_CREATED\r\nErrorDocument 202 \/202_ACCEPTED\r\nErrorDocument 203 \/203_NON_AUTHORITATIVE\r\nErrorDocument 204 \/204_NO_CONTENT\r\nErrorDocument 205 \/205_RESET_CONTENT\r\nErrorDocument 206 \/206_PARTIAL_CONTENT\r\nErrorDocument 207 \/207_MULTI_STATUS\r\nErrorDocument 300 \/300_MULTIPLE_CHOICES\r\nErrorDocument 301 \/301_MOVED_PERMANENTLY\r\nErrorDocument 302 \/302_MOVED_TEMPORARILY\r\nErrorDocument 303 \/303_SEE_OTHER\r\nErrorDocument 304 \/304_NOT_MODIFIED\r\nErrorDocument 305 \/305_USE_PROXY\r\nErrorDocument 307 \/307_TEMPORARY_REDIRECT\r\nErrorDocument 400 \/400_BAD_REQUEST\r\nErrorDocument 401 \/401_UNAUTHORIZED\r\nErrorDocument 402 \/402_PAYMENT_REQUIRED\r\nErrorDocument 403 \/403_FORBIDDEN\r\nErrorDocument 404 \/404_NOT_FOUND\r\n \r\nErrorDocument 405 \/405_METHOD_NOT_ALLOWED\r\nErrorDocument 406 \/406_NOT_ACCEPTABLE\r\nErrorDocument 407 \/407_PROXY_AUTHENTICATION_REQUIRED\r\nErrorDocument 408 \/408_REQUEST_TIME_OUT\r\nErrorDocument 409 \/409_CONFLICT\r\nErrorDocument 410 \/410_GONE\r\nErrorDocument 411 \/411_LENGTH_REQUIRED\r\nErrorDocument 412 \/412_PRECONDITION_FAILED\r\nErrorDocument 413 \/413_REQUEST_ENTITY_TOO_LARGE\r\nErrorDocument 414 \/414_REQUEST_URI_TOO_LARGE\r\nErrorDocument 415 \/415_UNSUPPORTED_MEDIA_TYPE\r\nErrorDocument 416 \/416_RANGE_NOT_SATISFIABLE\r\nErrorDocument 417 \/417_EXPECTATION_FAILED\r\nErrorDocument 422 \/422_UNPROCESSABLE_ENTITY\r\nErrorDocument 423 \/423_LOCKED\r\nErrorDocument 424 \/424_FAILED_DEPENDENCY\r\nErrorDocument 426 \/426_UPGRADE_REQUIRED\r\nErrorDocument 500 \/500_INTERNAL_SERVER_ERROR\r\nErrorDocument 501 \/501_NOT_IMPLEMENTED\r\nErrorDocument 502 \/502_BAD_GATEWAY\r\nErrorDocument 503 \/503_SERVICE_UNAVAILABLE\r\nErrorDocument 504 \/504_GATEWAY_TIME_OUT\r\nErrorDocument 505 \/505_VERSION_NOT_SUPPORTED\r\nErrorDocument 506 \/506_VARIANT_ALSO_VARIES\r\nErrorDocument 507 \/507_INSUFFICIENT_STORAGE\r\nErrorDocument 510 \/510_NOT_EXTENDED<\/pre>\n<h3>Online .htaccess Webapps<\/h3>\n<ul>\n<li><a target=\"_blank\" href=\"https:\/\/www.htaccessbuilder.com\" rel=\"noopener\">Htaccess Builder<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/www.htaccessredirect.net\/\" rel=\"noopener\">.htaccess redirect generator<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/www.htaccesseditor.com\/en.shtml\" rel=\"noopener\">.htaccessEditor \u2013 Create a .htaccess File<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/www.generateit.net\/mod-rewrite\/\" rel=\"noopener\">Mod Rewrite Generator by GenerateIt.net<\/a><\/li>\n<\/ul>\n<h3>Other Useful Resources<\/h3>\n<ul>\n<li><a target=\"_blank\" href=\"https:\/\/cwiki.apache.org\/confluence\/display\/httpd\/Htaccess\" rel=\"noopener\">.htaccess in Httpd Wiki<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/httpd.apache.org\/docs\/current\/howto\/htaccess.html\" rel=\"noopener\">Official Apache htaccess Documentation<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/www.askapache.com\/category\/htaccess\/\" rel=\"noopener\">Ask Apache Blog \u2013 Htaccess Archives<\/a><\/li>\n<li><a target=\"_blank\" href=\"http:\/\/serverfault.com\/questions\/214512\/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-as\" rel=\"noopener\">Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask<\/a><\/li>\n<\/ul>\n<h2>Final Thoughts<\/h2>\n<p>There are so many countless resources online discussing .htaccess files. My linked articles and webapps are a great place to get started. But keep practicing new ideas and don\u2019t be afraid of <strong>testing out code snippets<\/strong>. As long as <strong>you have a backup file<\/strong> then you can test out anything you like and it is a fun learning experience.<\/p>\n<p><strong>If you have other ideas or suggestions about .htaccess management please share with us in the post discussion area below.<\/strong><\/p>","protected":false},"excerpt":{"rendered":"<p>Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing engines, URL redirects, and many other crucial features. Designers or developers who are not very technical may not get into the specifics of managing their own .htaccess file. But the topic&hellip;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[952,510,511],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>A Beginner&#039;s Guide to .htaccess for Designers and Developers - Hongkiat<\/title>\n<meta name=\"description\" content=\"Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Beginner&#039;s Guide to .htaccess for Designers and Developers\" \/>\n<meta property=\"og:description\" content=\"Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-30T13:01:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-31T11:02:28+00:00\" \/>\n<meta name=\"author\" content=\"Jake Rocheleau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake Rocheleau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"A Beginner&#8217;s Guide to .htaccess for Designers and Developers\",\"datePublished\":\"2022-08-30T13:01:03+00:00\",\"dateModified\":\"2023-03-31T11:02:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/\"},\"wordCount\":1748,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"keywords\":[\"htaccess\",\"Web Designers\",\"Web Developers\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/\",\"name\":\"A Beginner's Guide to .htaccess for Designers and Developers - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"datePublished\":\"2022-08-30T13:01:03+00:00\",\"dateModified\":\"2023-03-31T11:02:28+00:00\",\"description\":\"Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/guide-to-htaccess\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Beginner&#8217;s Guide to .htaccess for Designers and Developers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\",\"name\":\"Jake Rocheleau\",\"description\":\"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/jake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"A Beginner's Guide to .htaccess for Designers and Developers - Hongkiat","description":"Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing","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:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/","og_locale":"en_US","og_type":"article","og_title":"A Beginner's Guide to .htaccess for Designers and Developers","og_description":"Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing","og_url":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2022-08-30T13:01:03+00:00","article_modified_time":"2023-03-31T11:02:28+00:00","author":"Jake Rocheleau","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Jake Rocheleau","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"A Beginner&#8217;s Guide to .htaccess for Designers and Developers","datePublished":"2022-08-30T13:01:03+00:00","dateModified":"2023-03-31T11:02:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/"},"wordCount":1748,"commentCount":7,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"keywords":["htaccess","Web Designers","Web Developers"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/","url":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/","name":"A Beginner's Guide to .htaccess for Designers and Developers - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"datePublished":"2022-08-30T13:01:03+00:00","dateModified":"2023-03-31T11:02:28+00:00","description":"Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/guide-to-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"A Beginner&#8217;s Guide to .htaccess for Designers and Developers"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a","name":"Jake Rocheleau","description":"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/jake\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-52a","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/19354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=19354"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/19354\/revisions"}],"predecessor-version":[{"id":47084,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/19354\/revisions\/47084"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=19354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=19354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=19354"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=19354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}