• Resolved Daniel

    (@davil2008)


    Hello.
    I was editing the .htaccess file and added a few lines of code.
    firstly one to redirect to https.
    I saved and the site worked great.
    I then added one to add expires headers. I saved changes. this code didn’t work ( I now understand that this is because I placed it in the wrong place ) so I deleted it and added a different one. I probably deleted some other important code and now I got a 500 error. I can’t access the site or wp-admin. the code itself doesn’t matter because the problem wasn’t with the code, but something else I added.
    I’m now afraid to touche anything.
    Please help quickly.
    Thank you in advance.

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Assuming you edited .htaccess file in root directory, you should firstly change it back to default htaccess setup:

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

    From there, you can work on adding your custom lines.

    Thread Starter Daniel

    (@davil2008)

    OK, Thank you for your response. but even before I edited the file, I had more than this. Can I send all the current file, so you can see what could be ,missing ?

    Thread Starter Daniel

    (@davil2008)

    and I checked, I do have this code in the file. so the problem is probably with something else.

    Thread Starter Daniel

    (@davil2008)

    Moderator Yui

    (@fierevere)

    永子

    error 500 happens when you add some unsupported directive or there is a syntax error.

    Please show lines you’re trying to add.

    You can check apache error log, to see whats exactly is wrong in your .htaccess file.

    Thread Starter Daniel

    (@davil2008)

    Great !! Thank you.
    I’ll send you my current .htaccess file.

    firstly one to redirect to https.

    the 301 redirect to https version is at the beginning, though, as I mentioned I firstly added the redirect code only, saved and checked the site, and it was OK, and the redirect worked.

    I then added one to add expires headers. I saved changes. this code didn’t work ( I now understand that this is because I placed it in the wrong place ) so I deleted it and added a different one.

    the expires headers code is at the end of the file.
    It also may be that the problem isn’t with the code itself but that I deleted important code, so I would advise checking that too.
    and whats the apache error log ?
    sending the code in the next reply.

    • This reply was modified 4 years, 7 months ago by Daniel.
    Thread Starter Daniel

    (@davil2008)

    here is the full and current .htaccess file :

    # BEGIN WordPress
    # ??????? (?????) ??? BEGIN WordPress ???? END WordPress` ??
    # ????? ????? ?????, ??? ????? ???? ?? ??????? ??????? ?? ???????.
    # ?? ????? ??????? ??? ?????? ??? ????.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>
    </IfModule>
    <ifModule mod_headers.c>
    Header set X-Endurance-Cache-Level “2”
    </ifModule>
    Options -Indexes

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/wp-content/endurance-page-cache/ – [L]
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/endurance-page-cache/$1/_index.html -f
    RewriteRule ^(.*)$ /wp-content/endurance-page-cache/$1/_index.html [L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault “access plus 1 month”
    ExpiresByType image/gif “access plus 1 year”
    ExpiresByType image/png “access plus 1 year”
    ExpiresByType image/jpg “access plus 1 year”
    ExpiresByType image/jpeg “access plus 1 year”
    ExpiresByType image/x-icon “access plus 1 year”
    ExpiresByType text/css “access plus 1 month”
    ExpiresByType application/javascript “access plus 1 year”
    </IfModule>

    # END WordPress

    # php — BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php73” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
    </IfModule>
    # php — END cPanel-generated handler, do not edit

    Thread Starter Daniel

    (@davil2008)

    OK. I was trying to explore to see the issue in the apache error logs and finally got this error :
    https://ibb.co/GcGsBvS

    Thread Starter Daniel

    (@davil2008)

    I also discovered several errors : ( justcook.co.il, the site that the issue is occurring, is an addon domain and it’s subdomain is justcook.vilenchik.net. the primary domain of justcook.co.il is vilenchik.net, and jeshv80 is, I think it’s database. ).

    [Sat Aug 01 07:28:22.368590 2020] [core:alert] [pid 953771:tid 139715906311936] [client 207.46.13.49:14626] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section
    [Sat Aug 01 07:25:41.190782 2020] [core:alert] [pid 945337:tid 139715864348416] [client 109.186.162.171:51375] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section, referer: https://justcook.co.il/$1
    [Sat Aug 01 07:25:40.252234 2020] [core:alert] [pid 953771:tid 139716132914944] [client 109.186.162.171:51373] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section
    [Sat Aug 01 07:24:16.926096 2020] [core:alert] [pid 945337:tid 139715889526528] [client 192.0.101.226:30816] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section
    [Sat Aug 01 07:21:27.398850 2020] [core:alert] [pid 916378:tid 139715973453568] [client 109.186.162.171:51288] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section, referer: https://justcook.vilenchik.net/
    [Sat Aug 01 07:21:26.559435 2020] [core:alert] [pid 916378:tid 139715897919232] [client 109.186.162.171:51286] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section
    [Sat Aug 01 07:16:48.725429 2020] [core:alert] [pid 912648:tid 139716132914944] [client 192.0.101.226:51673] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section
    [Sat Aug 01 07:14:33.223955 2020] [core:alert] [pid 905018:tid 139716334339840] [client 54.204.127.223:20023] /home3/jeshv80/justcook.co.il/.htaccess: </IfModule> without matching <IfModule> section

    • This reply was modified 4 years, 7 months ago by Daniel.
    Moderator Yui

    (@fierevere)

    永子

    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>
    </IfModule>
    <ifModule mod_headers.c>

    duplicate </IfModule> directive.
    remove one

    Thus is not recommended to insert any custom rules between
    #Begin WordPress
    and
    #END WordPress

    insert your rules before or after this block. WordPress will overwrite anything in this block.

    Thread Starter Daniel

    (@davil2008)

    Thank you so much !! I deleted one of the <ifmodule> rules and the site went back to normal !! Thank you for your support !!
    And you suggest to insert the custom code after the #end wordpress section, should I insert it right after the #end wordpress or after everything ?

    Moderator Yui

    (@fierevere)

    永子

    # 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

    this is default block for WordPress rewrite rules, it can be overwritten when you visit Permalinks settings page or on some events defined by plugin hooks.

    You can put your rules before AND after it, but not inside.

    Thread Starter Daniel

    (@davil2008)

    OK, thank you !!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘500 error after editing .htaccess’ is closed to new replies.