• Hello guys! I want to optimize my website for faster loading and less CPU cycles of my host.

    I started with the “.htaccess” file and “cloudflare”, but I encounter problems with both.

    1. ‘.htaccess’ error when attempting to activate all redirects to be to “https://www.” from my cPanel “redirects” part:
    The system failed to add the redirect because of the following errors:

    Error:

    Apache detected an error in the Rewrite config.

    httpd: Syntax error on line 50 of /home/Domain/public_html/.htaccess.pY4l8ozyHLHkPSkYnE3IJWJU7nxg5Jne: </Directory> without matching <Directory> section 

    Please try again.

    .htaccess file:
    Header set Cache-Control "max-age=2628000, public"
    <IfModule mod_alias.c>

    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType application/javascript "access 1 month"
    ExpiresByType application/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 2 days"
    </IfModule>
    ## EXPIRES CACHING ##

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress
    AddHandler application/x-httpd-php56 .php .php5 .php4 .php3

    2. Cloudflare error: “error too many redirects” -> solution activate only “https” redirects” (not found in the cPanel “cloudflare” section, I only have the “activate” button).

    Can anyone please tell me if they are ok:

Viewing 1 replies (of 1 total)
  • Hi, it seems you’re adding redirects in cPanel as well. Follow the below approach:

    1) Fix the site so that it loads first. (That means, remove all redirects from cPanel, remove Cloudflare dependency, set htaccess to default).

    2) Once the site loads, re-do the optimization without adding cPanel redirect.

    Here’s the dafault htaccess code:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Also, here’s a free collection of video tuts to help you optimize: https://workwithwp.com/courses/speedup-your-wordpress/

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Problems with optimizing website’ is closed to new replies.