<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dennis Hüttner</title>
    <description>The latest articles on DEV Community by Dennis Hüttner (@dhuettner).</description>
    <link>https://dev.to/dhuettner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F570684%2F9f21bacf-1ac6-4c2c-8a44-590971d8343d.jpeg</url>
      <title>DEV Community: Dennis Hüttner</title>
      <link>https://dev.to/dhuettner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhuettner"/>
    <language>en</language>
    <item>
      <title>Why a local WordPress installation is worth it</title>
      <dc:creator>Dennis Hüttner</dc:creator>
      <pubDate>Wed, 26 Jan 2022 08:14:34 +0000</pubDate>
      <link>https://dev.to/dhuettner/force-https-with-htaccess-3lhn</link>
      <guid>https://dev.to/dhuettner/force-https-with-htaccess-3lhn</guid>
      <description>&lt;p&gt;Do you know this: You are testing a function or have made a change to your WordPress website, but then all the work is in vain because the site crashed?&lt;/p&gt;

&lt;p&gt;A remedy for this can be an installation and test environment for WordPress on the local computer. This allows you to develop and test your WordPress website offline without risk, as the online environment is simulated on your own computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modify your website in a secure programming environment
&lt;/h2&gt;

&lt;p&gt;You will also need to make adjustments to your WordPress website from time to time (e.g. a new theme or installing plug-ins). You should test these changes first before using them live on your website. Fortunately, there is a simple solution for this.&lt;/p&gt;

&lt;p&gt;There are two types of server environments: Local and Remote. A local server is hosted directly on your own computer, while a remote server is hosted at another location. Which server model is best for testing is up to you.&lt;/p&gt;

&lt;p&gt;However, for development and testing, it is recommended to install a local version of your website on your own computer instead of doing development and testing on a remote server.&lt;/p&gt;

&lt;p&gt;If your site is brand new and not publicly available, testing directly on the site is less risky. However, if you already have a running website, it is not recommended to test directly on the site (to avoid downtime and possible security vulnerabilities).&lt;/p&gt;

&lt;p&gt;It's better to work with a local server that only you have access to, and declare your already published website a test-free zone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test your WordPress website locally
&lt;/h2&gt;

&lt;p&gt;Installing WordPress locally on your computer creates a perfect testing environment for making changes, experimenting, theme development, plug-in testing, and developing your website.&lt;/p&gt;

&lt;p&gt;By having a local server on your computer, you can also develop and design your WordPress website in offline mode. This way, you can test your website and see how it would look online without being connected to the Internet. Working with a local server also speeds up development, as no internet connection is required and communication is direct with the server.&lt;/p&gt;

&lt;p&gt;Most importantly, you can make changes to your site in a protected environment without compromising the data integrity of your web presence. Since a locally operated website is not on the Internet, hacker attacks and security breaches are almost impossible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a local testing platform with MAMP
&lt;/h2&gt;

&lt;p&gt;All you need to set up a local testing environment is free open source server software like MAMP, WAMP or XAMPP. This gives you all the means to run WordPress locally on your computer for development and testing purposes.&lt;/p&gt;

&lt;p&gt;Originally developed only for Mac OS, MAMP now also runs on Windows and Linux. While WAMP is only compatible with Windows, XAMPP works on many platforms (Windows, Mac OS, Linux, Solaris).&lt;br&gt;
If you are a Mac user, MAMP is the easiest to use and the best way to run your website locally.&lt;/p&gt;

&lt;p&gt;The term MAMP is an acronym for Mac OS (operating system), Apache (local web server), MySQL (database management system) and PHP, Perl or Python (programming language). The MAMP package contains all the software you need to run WordPress locally.&lt;/p&gt;

&lt;p&gt;Setting up MAMP is very straightforward. To create a local server, you install a software package and a database on your computer.&lt;/p&gt;

&lt;p&gt;To get started, you go to the MAMP website to get to the free MAMP download (the premium MAMP PRO costs a bit). The MAMP installer will guide you through the steps necessary to install the software. More step-by-step instructions can be found on the MAMP website.&lt;/p&gt;

&lt;p&gt;Connect me on &lt;a href="https://www.twitter.com/proofwebwizard" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, &lt;a href="https://www.linkedin.com/company/waterproof-web-wizard" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and &lt;a href="https://github.com/dhuettner" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;Visit my &lt;a href="https://waterproof-web-wizard.com/blog" rel="noopener noreferrer"&gt;Blog&lt;/a&gt; for more articles like this.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>webdev</category>
      <category>localdev</category>
    </item>
    <item>
      <title>Force Https with .htaccess</title>
      <dc:creator>Dennis Hüttner</dc:creator>
      <pubDate>Wed, 29 Dec 2021 12:34:00 +0000</pubDate>
      <link>https://dev.to/dhuettner/force-https-with-htaccess-5bb9</link>
      <guid>https://dev.to/dhuettner/force-https-with-htaccess-5bb9</guid>
      <description>&lt;p&gt;After installing an SSL certificate, your website will be accessible via HTTP and HTTPS. However, it is better to use only the latter, because it encrypts and additionally secures the data of your website. With some hosters there is a setting in the web interface to force HTTPS with just one click. Unfortunately, it happens again and again that this setting does not work correctly with various CMS systems. You can also use the .htaccess file (which we recommend) to force an HTTPS connection.  This tutorial shows you how to do that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Force HTTPS for all traffic
&lt;/h2&gt;

&lt;p&gt;One of the many options you have with .htaccess files is to redirect HTTP traffic to HTTPS. You can enable the feature to force HTTPS for all incoming traffic by following the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to the file manager in your hosting panel and open the .htaccess in the appropriate folder where your domain points to. If the file is not there, you may need to create and/or share it.&lt;/li&gt;
&lt;li&gt;Scroll down until you find "RewriteEngine On" and paste the following lines of code below it:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;RewriteEngine&lt;/span&gt; &lt;span class="nc"&gt;On&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteCond&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTPS&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteRule&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="o"&gt;://%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTP_HOST&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;REQUEST_URI&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Save the change.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;IMPORTANT: Make sure that the line "RewriteEngine On" does not appear twice. If the line already exists, simply copy the rest of the code without it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Forcing HTTPS for a specific domain
&lt;/h2&gt;

&lt;p&gt;If you have two domains that both point to the same website, but only the first domain should be redirected to https (for whatever reason), you can use the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;RewriteEngine&lt;/span&gt; &lt;span class="nc"&gt;On&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteCond&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTP_HOST&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;yourdomain&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="n"&gt;de&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;NC&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteCond&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTPS&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteRule&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="o"&gt;://%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTP_HOST&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;REQUEST_URI&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nc"&gt;L&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Force HTTPS for a specific folder
&lt;/h2&gt;

&lt;p&gt;The .htaccess file can also be used to force HTTPS for specific folders. However, the file should be placed in the folder that is to establish the HTTPS connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;RewriteEngine&lt;/span&gt; &lt;span class="nc"&gt;On&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteCond&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTPS&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;off&lt;/span&gt; 
&lt;span class="nc"&gt;RewriteRule&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;folder1&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;folder2&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;folder3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="o"&gt;://%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;HTTP_HOST&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;REQUEST_URI&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nc"&gt;L&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the "folder" with your "directory".&lt;/p&gt;

&lt;p&gt;After you have made the changes, clear your browser's cache and try to connect to your website via HTTP. If everything was added correctly, it will now redirect to the HTTPS version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! You have just successfully edited your .htaccess file and redirected all HTTP traffic to the secure version HTTPS. Depending on the platform you developed your site on, there may be alternative methods to enable this feature.&lt;/p&gt;

&lt;p&gt;If you have any tips, tricks, or suggestions to share with us, we welcome your comments!&lt;/p&gt;

&lt;p&gt;Connect me on &lt;a href="https://www.twitter.com/proofwebwizard" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, &lt;a href="https://www.linkedin.com/company/waterproof-web-wizard" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and [GitHub]!&lt;/p&gt;

&lt;p&gt;Visit my &lt;a href="https://waterproof-web-wizard.com/blog" rel="noopener noreferrer"&gt;Blog&lt;/a&gt; for more articles like this.&lt;/p&gt;

</description>
      <category>htaccess</category>
      <category>https</category>
    </item>
  </channel>
</rss>
