Category: htaccess

  • How to increase the maximum file upload size limit in PHP & phpMyAdmin?

    How to increase the maximum file upload size limit in PHP & phpMyAdmin?

    Introduction –

    By default, cPanel establishes a maximum file upload limit of 2GB. Please refer to this guide to raise the upload threshold.

    Procedure-

    • šŸ‘‰ Step-1: Log into WHM
    • šŸ‘‰ Step-2: Navigate to “WHM / Software / MultiPHP INI Editor”
    • šŸ‘‰ Step-3: Select the version of PHP that your site uses
    • šŸ‘‰ Step-4: Increase the following variables
      1. upload_max_filesize
      2. post_max_size (This should be larger than or equal to upload_max_filesize)
      3. memory_limit (This should be larger than or equal to post_max_size)
      4. max_execution_time (Optional, but can prevent timeout errors for large files)
    • šŸ‘‰ Step-5: Click “Apply”
    • šŸ‘‰ Step-6: Repeat for all versions of PHP that you require larger file upload sizes for.

    NOTE: Please note, the maximum size for these variables is 2GB.

  • How To Redirect HTTP to HTTPS using .htaccess file (Apache Server)

    How To Redirect HTTP to HTTPS using .htaccess file (Apache Server)

    When you are adding SSLĀ for your websitesĀ to make it’s secure, your web server will also continue to serve the HTTP version of your webpages. So to get Website Visitor/your audiences’ attraction, you need to redirect HTTP to HTTPS, and force SSL on your website. Here’s I am giving some examples ā€œhow to redirect HTTP to HTTPs using .htaccess file in Apache web serverā€.

    Steps to Redirect HTTP To HTTPS Using .Htaccess File

    Before you start the things-Kindly ensure you have mod_rewrite enabled in your Apache server. Then only your Apache server will apply the configuration in .htaccess file. After migratingĀ your website from HTTP to HTTPS, you may need to use a database reporting software for monitoring the key metrics about your website/application like signups, purchases, revenue, etc. with the help of dashboards & charts, to make sure everything is working smoothly and issues are spotted early.

    Open .htaccess file

    You will usually find .htaccess file in the root folder (e.g /var/www/html/) of your site. You can open it with the help of code editor

    $ sudo vim /var/www/html/.htaccess

    Add Rewrite Rule to .htaccess

    Add the below mentioned rules to your .htaccess file, for redirecting HTTP to HTTPs

    RewriteEngine on

    # force ssl

    RewriteCond %{SERVER_PORT} ^80$

    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    If the requested port is 80 (default for HTTP) then the above rewrite condition will check. In that case, it will match the entire URL and redirect to its HTTPS version. The serverĀ variable for website’s root URL is SERVER_NAME, and the URL stub that follows the domainĀ name is REQUEST_URI. For permanent redirect here we use a 301 redirect. If you don’t need a permanent redirect then just use ā€˜R’ instead of ā€˜R=301’ in the above RewriteRule.

    By using virtual hostsĀ also, you can redirect HTTP to HTTPS in your virtual host’s config file.

    <VirtualHost *:80>

    ServerName www.example.com

    Redirect permanent / https://www.example.com/

    </VirtualHost>

     

    <VirtualHost _default_:443>

    ServerName www.example.com

    DocumentRoot /var/www/html/example

    SSLEngine On

    # etc…

    </VirtualHost>

     

    In above mentioned case, we want to set up 2 virtual hosts – one for HTTP and the other one for HTTPS. The HTTP virtual host easily redirects all its requests to the HTTPs one. You can even use URL redirection to redirect to subfolder or redirect subfolder to subdomain.

    Restart Apache Server

    Restart Apache Server to apply changes

    $ sudo service apache2 restart

    Enjoy!

    For more guidance contact experts!