<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>apache on Tutes Club</title><link>https://tutes.in/tag/apache/</link><description>Recent content in apache on Tutes Club</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 23 Jan 2019 10:03:37 +0000</lastBuildDate><atom:link href="https://tutes.in/tag/apache/index.xml" rel="self" type="application/rss+xml"/><item><title>How to use .htaccess to run all .html files as .php by using PHP handlers in Apache w/o CGI?</title><link>https://tutes.in/how-to-use-htaccess-to-run-all-html-files-as-php-by-using-php-handlers-in-apache-w-o-cgi/</link><pubDate>Wed, 23 Jan 2019 09:52:54 +0000</pubDate><guid>https://tutes.in/how-to-use-htaccess-to-run-all-html-files-as-php-by-using-php-handlers-in-apache-w-o-cgi/</guid><description>&lt;p&gt;If you are not able to find the correct Handler, Simply create a .php file with the following contents:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nx"&gt;php&lt;/span&gt; &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$_SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;REDIRECT_HANDLER&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and run/open this file in browser.&lt;/p&gt;
&lt;figure&gt;&lt;a href="https://tutes.in/wp-content/uploads/2019/01/application-handler.png"&gt;
&lt;img loading="lazy" src="https://tutes.in/wp-content/uploads/2019/01/application-handler.png"
alt="application httpd handler"/&gt; &lt;/a&gt;&lt;figcaption&gt;
&lt;p&gt;example application handler&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Use this output in .htaccess file&lt;/p&gt;
&lt;p&gt;Create a &lt;code&gt;.htaccess&lt;/code&gt; file at the root of your website(usually a folder named &lt;em&gt;public_html&lt;/em&gt; or &lt;em&gt;htdocs&lt;/em&gt; on linux servers) and add this line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AddType [[THE OUTPUT FROM ABOVE FILE]] .html .htm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Example&lt;/p&gt;</description></item><item><title>Common PHP.ini directives list for Apache htaccess files</title><link>https://tutes.in/common-php-ini-directives-list-for-apache-htaccess-files/</link><pubDate>Tue, 30 Oct 2018 18:37:38 +0000</pubDate><guid>https://tutes.in/common-php-ini-directives-list-for-apache-htaccess-files/</guid><description>&lt;p&gt;Maximum Execution Time and Maximum Input Time&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value max_execution_time 300
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value max_input_time 300
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Max Upload file size and Max POST data size&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value upload_max_filesize 20M
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value post_max_size 21M
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output buffering toggle&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value output_buffering on
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# OR
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value output_buffering 16384
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Expose PHP signature – toggle&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value expose_php on
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Maximum Input variables&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value max_input_vars 1500
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Maximum Memory Limit for PHP&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value memory_limit 1256M
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Magic Quotes toggle&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_value magic_quotes_gpc on
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Register Global Variables – useless now&lt;/p&gt;</description></item><item><title>Default .htaccess file for wordpress with compression and caching tweaks</title><link>https://tutes.in/default-htaccess-file-for-wordpress-with-compression-and-caching-tweaks/</link><pubDate>Tue, 09 Oct 2018 16:06:06 +0000</pubDate><guid>https://tutes.in/default-htaccess-file-for-wordpress-with-compression-and-caching-tweaks/</guid><description>&lt;p&gt;Here is the default .htaccess file for wordpress&lt;/p&gt;
&lt;p&gt;If you are using cpanel, before you proceed make sure that you don’t have htaccess file already. Default File Manager settings in cpanel make it hidden&lt;/p&gt;
&lt;figure class="align-center "&gt;&lt;a href="https://tutes.in/wp-content/uploads/2018/10/hidden-htaccess.jpg"&gt;
&lt;img loading="lazy" src="https://tutes.in/wp-content/uploads/2018/10/hidden-htaccess.jpg#center"
alt="Default Settings in cPanel File Manager"/&gt; &lt;/a&gt;&lt;figcaption&gt;
&lt;p&gt;Default Settings in cPanel File Manager&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="htaccess-file--default-code-for-wordpress"&gt;.htaccess file – default code for wordpress&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# BEGIN WordPress
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;ifmodule mod_rewrite.c&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteEngine On
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteBase /
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule ^index\.php$ - [L]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{REQUEST_FILENAME} !-f
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{REQUEST_FILENAME} !-d
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule . /index.php [L]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/ifmodule&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# END WordPress
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If your WordPress Installation is inside a directory say &lt;code&gt;knowledge&lt;/code&gt;, which means your wordpress url is &lt;code&gt;https://abcd.com/knowledge/&lt;/code&gt; then htaccess code would be&lt;/p&gt;</description></item><item><title>.htaccess redirect from http to https and from non-www to www redirect – Make site permanently SSL secured</title><link>https://tutes.in/htaccess-redirect-from-http-to-https-and-from-non-www-to-www-redirect-make-site-permanently-ssl-secured/</link><pubDate>Fri, 27 Jul 2018 06:10:09 +0000</pubDate><guid>https://tutes.in/htaccess-redirect-from-http-to-https-and-from-non-www-to-www-redirect-make-site-permanently-ssl-secured/</guid><description>&lt;p&gt;put this in your htaccess file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{HTTP_HOST} !^www\.(.*)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{HTTPS} !=on
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Forcing website to https and www using htaccess on apache servers</title><link>https://tutes.in/forcing-website-to-https-and-www-using-htaccess-on-apache-servers/</link><pubDate>Wed, 21 Feb 2018 17:45:20 +0000</pubDate><guid>https://tutes.in/forcing-website-to-https-and-www-using-htaccess-on-apache-servers/</guid><description>&lt;p&gt;To first force HTTPS, you must check the correct environment variable %{HTTPS} off, but your rule above then prepends the www. Since you have a second rule to enforce www., don’t use it in the first rule.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{HTTPS} off
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# First rewrite to HTTPS:
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Don&amp;#39;t put www. here. If it is already there it will be included, if not
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# the subsequent rule will catch it.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Now, rewrite any request to the wrong domain to use www.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# [NC] is a case-insensitive match
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{HTTP_HOST} !^www\. [NC]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>CORS policy for subdomains – htaccess – apache server</title><link>https://tutes.in/cors-policy-for-subdomains-htaccess-apache-server/</link><pubDate>Wed, 20 Dec 2017 20:09:01 +0000</pubDate><guid>https://tutes.in/cors-policy-for-subdomains-htaccess-apache-server/</guid><description>&lt;p&gt;Works for Magento 2.2x&lt;/p&gt;
&lt;p&gt;Cross-Origin Resource Sharing header for Access-Control-Allow-Origin for Subdomains&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SetEnvIf Origin &amp;#34;^(.*\.yourdomain\.com)$&amp;#34; OSD=$1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Header set Access-Control-Allow-Origin &amp;#34;%{OSD}e&amp;#34; env=OSD
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Header set Access-Control-Allow-Methods: &amp;#34;*&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Header set Access-Control-Allow-Headers: &amp;#34;*&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or a general format for simple copy paste:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SetEnvIf Origin &amp;#34;^(.*)$&amp;#34; OSD=$1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Header set Access-Control-Allow-Origin &amp;#34;%{OSD}e&amp;#34; env=OSD
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Header set Access-Control-Allow-Methods: &amp;#34;*&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Header set Access-Control-Allow-Headers: &amp;#34;*&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>How to secure a folder by whitelisting one IP using HTACCESS and denying all others</title><link>https://tutes.in/how-to-secure-a-folder-by-whitelisting-one-ip-using-htaccess-and-denying-all-others/</link><pubDate>Thu, 26 Oct 2017 22:19:06 +0000</pubDate><guid>https://tutes.in/how-to-secure-a-folder-by-whitelisting-one-ip-using-htaccess-and-denying-all-others/</guid><description>&lt;p&gt;The process involves matching all requests for an IP, if the IP does not match redirect all secured directory requests.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{REMOTE_ADDR} !^120\.120\.120\.120
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule ^admin/.* - [L,R=403]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{REMOTE_ADDR} ^120\.120\.120\.120
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule ^admin$ - [L,R=403]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want to control this IP using a script, you can add 2 lines&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;###CUSTOM RULES###
# your rules will appear here using php script
###CUSTOM RULES###
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now add a script, say happy.php&lt;br&gt;
and use the following code:&lt;/p&gt;</description></item></channel></rss>