{"id":755,"date":"2020-01-10T05:25:10","date_gmt":"2020-01-10T11:25:10","guid":{"rendered":"https:\/\/Aldersoft.CA\/prod\/wordpress\/?page_id=755"},"modified":"2020-03-15T05:58:16","modified_gmt":"2020-03-15T10:58:16","slug":"apache-faq","status":"publish","type":"page","link":"https:\/\/Aldersoft.CA\/prod\/wordpress\/resources\/tools-and-tips\/apache-faq\/","title":{"rendered":"Apache WebServer FAQ"},"content":{"rendered":"<h2><strong><span style=\"color: #ff0000;\">Here are some frequently asked questions about Apache WebServers.<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\"><strong><div class=\"hrf-faq-list\"><article class=\"hrf-entry\" id=\"hrf-entry-750\">\n                      <h3 class=\"hrf-title close-faq\" data-content-id=\"hrf-content-750\"><span><\/span>How do I force all requests to use HTTPS ?<\/h3>\n                     <div class=\"hrf-content\" id=\"hrf-content-750\"><p><span style=\"color: #000000;\"><strong>After you add an SSL Certificate to your website, people may still try to connect to it using HTTP, which is considered insecure these days.<\/strong><\/span><br \/>\n<span style=\"color: #000000;\"><strong>To address this, you can either create a separate directory for &#8220;secure&#8221; pages or simply redirect pages to always use HTTPS. If you are using an Apache webserver.<br \/>\nAdd the following to the beginning of your .htaccess file.<\/strong><\/span><\/p>\n<p style=\"padding-left: 80px;\"><span style=\"color: #0000ff;\"><strong>#BEGIN HTTPS Redirect<br \/>\n&lt;IfModule mod_rewrite.c&gt;<br \/>\nRewriteEngine On<br \/>\nRewriteCond %{HTTPS} off<br \/>\nRewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<br \/>\n&lt;\/IfModule&gt;<br \/>\n#END HTTPS Redirect<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>This essentially says: <\/strong><\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\"><strong>Is the Apache rewrite module loaded?<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>If so, then turn it on.<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>Is this an unsecured request (URL) that was sent?<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>Ok, then rebuild the whole URL to put https:\/\/ in the front of the URL to make it a secure request.<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>When done, Redirect to the new URL and mark this as a permanent redirect [R=301]<br \/>\nNote. You can also redirect with just R or R=302. The 302 says this is a temporary redirect.<br \/>\nOften webservers will remember permanent redirects and will cache them for speed.<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>Leave .htaccess and go no further. [L]<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>The whole process will start over from scratch again. However, this time through it will be https:\/\/&#8230;<\/strong><\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><strong>Note. Thank you Jacob Buller of <a href=\"https:\/\/EcoVillages.CA\" target=\"_blank\" rel=\"noopener\">EcoVillages.CA<\/a> for your help in debugging this.<\/strong><\/span><\/p>\n<\/div>\n                  <\/article><article class=\"hrf-entry\" id=\"hrf-entry-751\">\n                      <h3 class=\"hrf-title close-faq\" data-content-id=\"hrf-content-751\"><span><\/span>Why do I keep getting &#8220;too many redirects&#8221; when I retrieve the Home Page, but not any other page ?<\/h3>\n                     <div class=\"hrf-content\" id=\"hrf-content-751\"><p><span style=\"color: #000000;\"><strong>This can be caused by a number of things, however, if you use more than one &#8220;environment&#8221; under your registered website name, this solution should fix this for you. <\/strong><\/span><span style=\"color: #000000;\"><strong>Also, if you have recently switched from Plain PermaLinks to %postname% PermaLinks or others, you may run into this problem as well.<br \/>\n<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>By &#8220;environments&#8221;, I mean things like test, devl, next (stage), prod, etc. These are normally called sub-domains. They could also be different language translations. EG. en, fr, es, ru, etc. Regardless, the situation results in too many redirects as WordPress does not automatically redirect to index.php when the URL ends with a directory name with or without a trailing \/, resulting in an infinite loop.<br \/>\n<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>For example: If you have registered MySite.com, the internet will direct your request to where your main site is located. EG. https:\/\/MySite.com. You may have two environments, stage and prod, which is quite common and strongly recommended. Stage is where you make your changes and test them, prod is your environment that the world sees.<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong><br \/>\nHence you have two WordPress installations: https:\/\/MySite.com\/stage and https:\/\/MySite\/prod. You normally want prod to be your &#8220;goto&#8221; WordPress site, so you put a redirect into the MySite.com &#8220;home&#8221; directory to send people automatically to prod. For example, you would create an index.php file in your home directory which contains the following redirect. (Note. The home directory is usually public_html in your cPanel File Manager.)<br \/>\n<\/strong><\/span><\/p>\n<p style=\"padding-left: 80px;\"><span style=\"color: #0000ff;\"><strong>&lt;?php<\/strong><br \/>\n<strong>\/* Redirect to MySite.com\/prod with a permanent redirect *\/<\/strong><br \/>\n<strong>header( &#8216;Location: https:\/\/MySite.com\/prod\/&#8217;, TRUE, 301 );<\/strong><br \/>\n<strong>?&gt;<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>You can access the other directories using the URL request. EG. https:\/\/MySite.com\/stage. Generally, this will partially work if you include a page name. EG. https:\/\/MySite.com\/stage\/about_us, however, the directives that WordPress inserts by default, break when no page name is specified. EG. https:\/\/MySite.com\/stage or https:\/\/MySite\/stage\/ and https:\/\/MySite.com\/prod or https:\/\/MySite.com\/prod and s<\/strong><\/span><span style=\"color: #000000;\"><strong>ince you have the redirect in the home directory, https:\/\/MySite.com<\/strong><strong> or https:\/\/MySite.com\/.<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong><br \/>\nUsing our example, you need to add the following to the beginning of the .htaccess file in public_html\/stage.<\/strong><\/span><\/p>\n<p style=\"padding-left: 80px;\"><strong><span style=\"color: #0000ff;\"># BEGIN Aldersoft Permalink fix<br \/>\n<\/span><\/strong><strong><span style=\"color: #0000ff;\"># Fix WordPress Permalink bug for URLS, not including index.php<br \/>\n&lt;IfModule mod_rewrite.c&gt;<br \/>\nRewriteEngine On<br \/>\nRewriteBase \/<br \/>\nRewriteRule .* &#8211; [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]<br \/>\n<\/span><\/strong><strong><span style=\"color: #0000ff;\">RewriteRule ^$ https:\/\/%{HTTP_HOST}\/stage\/index.php [R,L]<br \/>\nRewriteRule ^(.*)%{HTTP_HOST}$ $1%{HTTP_HOST}\/stage\/index.php [R,L]<br \/>\nRewriteRule ^(.*)%{HTTP_HOST}\/$ $1%{HTTP_HOST}\/stage\/index.php [R,L]<br \/>\n&lt;\/IfModule&gt;<br \/>\n#END Aldersoft Permalink Fix<\/span><\/strong><\/p>\n<p><strong><span style=\"color: #000000;\">and also the following needs to be added to the beginning of your .htaccess in public_html\/prod.<\/span><\/strong><\/p>\n<p style=\"padding-left: 80px;\"><strong><span style=\"color: #0000ff;\"># BEGIN Aldersoft Permalink fix<br \/>\n# Fix WordPress Permalink bug for URLS, not including index.php<br \/>\n&lt;IfModule mod_rewrite.c&gt;<br \/>\nRewriteEngine On<br \/>\nRewriteBase \/<br \/>\nRewriteRule .* &#8211; [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]<br \/>\nRewriteRule ^$ https:\/\/%{HTTP_HOST}\/prod\/index.php [R,L]<br \/>\nRewriteRule ^(.*)%{HTTP_HOST}$ $1%{HTTP_HOST}\/prod\/index.php [R,L]<br \/>\nRewriteRule ^(.*)%{HTTP_HOST}\/$ $1%{HTTP_HOST}\/prod\/index.php [R,L]<br \/>\n&lt;\/IfModule&gt;<br \/>\n#END Aldersoft Permalink Fix<\/span><\/strong><\/p>\n<p style=\"padding-left: 40px;\"><strong><span style=\"color: #000000;\">This essentially says: <\/span><\/strong><\/p>\n<ul>\n<li><strong><span style=\"color: #000000;\">Is the Apache rewrite module loaded?<\/span><\/strong><\/li>\n<li><strong><span style=\"color: #000000;\">If so, then start the Rewrite Engine<\/span><\/strong><\/li>\n<li><span style=\"color: #000000;\"><strong>Set the URL pointer to the end of the start of the<br \/>\n<\/strong><\/span><\/li>\n<li><strong><span style=\"color: #000000;\">If there was no data passed following the home directory,<br \/>\nThen rebuild the URL to point to https:\/\/MySite.com\/prod\/index.php<br \/>\nEG. https:\/\/MySite.com\/prod will have %{HTTP_HOST} of &#8220;MySite.com&#8221;<br \/>\nThis will be rebuilt as https:\/\/MySite.com\/prod\/index.php<br \/>\nLastly [R,L], says redirect (302) to the new URL, leave .htaccess, and start again.<\/span><\/strong><\/li>\n<li><strong><span style=\"color: #000000;\">If the URL ends immediately after the %{HTTP_HOST} EG. https:\/\/MySite.com or https:\/\/MySite.com\/prod<br \/>\nThen rebuild the URL to point to https:\/\/mysite.com\/prod\/index.php<br \/>\n<\/span><\/strong><span style=\"color: #000000;\"><strong>Lastly [R,L], says redirect (302) to the new URL, leave .htaccess, and start again.<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>If the URL ends with a \/ immediately after the %{HTTP_HOST}\/ EG. https:\/\/mysite.com\/prod\/<br \/>\nThen rebuild the URL to point to https:\/\/MySite.com\/prod\/index.php<br \/>\n<\/strong><strong>Lastly [R,L], says redirect (302) to the new URL, leave .htaccess, and start again.<\/strong><\/span><\/li>\n<\/ul>\n<p style=\"padding-left: 40px;\"><span style=\"color: #000000;\"><strong>Note. Thank you Jacob Buller of <a href=\"https:\/\/EcoVillages.CA\/\" target=\"_blank\" rel=\"noopener\">EcoVillages.CA<\/a> for your help in debugging this.<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n                  <\/article><article style = \"display:block;text-align:right; font-size:11px\">Powered by <a href=\"https:\/\/websitebuilderguide.com\/wp-plugins\/html5-responsive-faq-plugin-for-wordpress\/\" target=\"_blank\" rel=\"noopener\">HTML5 Responsive FAQ<\/a><\/article><\/div><!-- HRF v 2.8.4 --><\/strong><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are some frequently asked questions about Apache WebServers.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":104,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":"","_tec_slr_enabled":"","_tec_slr_layout":""},"class_list":["post-755","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Gary Alderson","author_link":"https:\/\/Aldersoft.CA\/prod\/wordpress\/author\/aldersoft\/"},"uagb_comment_info":0,"uagb_excerpt":"Here are some frequently asked questions about Apache WebServers.","ticketed":false,"_links":{"self":[{"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/pages\/755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/comments?post=755"}],"version-history":[{"count":0,"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/pages\/755\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/pages\/104"}],"wp:attachment":[{"href":"https:\/\/Aldersoft.CA\/prod\/wordpress\/wp-json\/wp\/v2\/media?parent=755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}