Home > Blockchain >  Internal Server Error when trying to change upload file size parameters in htaccess
Internal Server Error when trying to change upload file size parameters in htaccess

Time:09-27

I have edited a live WordPress site locally and am about to upload it to the live server. When doing this, I usually change (increase) the maximum file upload size since I am using a plugin to Export/Import the website, and this plugin only takes 100 MB of import file size (plugin: All in One WP Migration, free version).

When achieving this I add this code to the end of the .htaccess file located in the html folder:

php_value upload_max_filesize 1000M
php_value post_max_size 1000M
php_value memory_limit 1000M
php_value max_execution_time 0
php_value max_input_time 300

This typically works well, but this time this error message is shown in the browser (on page refresh):

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

  1. I have stripped the .htaccess file of code that is related to (and dynamically generated by) the Breeze cache plugin, and the site works as expected without this code (given that I have not added the "upload file size code" in the file).
  2. I have commented out the code related to GD-SSL (Godaddy SSL), and the site works as expected without this code (given that I have not added the "upload file size code" in the file). For reference, please see file content below.

This is what my .htaccess file looks like after these edits (edits made in order to solve the error, of course):

# BEGIN GD-SSL
# <IfModule mod_rewrite.c>
# Options  FollowSymLinks
# RewriteEngine On
# RewriteCond %{HTTPS} !=on
# RewriteCond %{HTTP_USER_AGENT} ^(. )$
# RewriteCond %{SERVER_NAME} ^alloptik\.se$ [OR]
# RewriteCond %{SERVER_NAME} ^49l\.fd7\.myftpupload\.com$
# RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Header add Strict-Transport-Security "max-age=300"
# Header always set Content-Security-Policy "upgrade-insecure-requests"
# </IfModule>
# END GD-SSL

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

php_value upload_max_filesize 1000M
php_value post_max_size 1000M
php_value memory_limit 1000M
php_value max_execution_time 0
php_value max_input_time 300

CodePudding user response:

Please use like below into wp-config.php file and remove your htaccess php_value. follow screenshoot below.

https://prnt.sc/7xitGHbSIFEn

@ini_set( 'upload_max_size' , '1000M' );
@ini_set( 'post_max_size', '1000M');
@ini_set( 'max_execution_time', '300' );

CodePudding user response:

You can only use php_value (and related) directives in .htaccess if PHP is installed as an Apache module, which is probably not the case in your live server environment. The 500 Internal Server Error is likely due to the directive simply not being recognised.

You can try using a per-directory .user.ini file instead (on CGI/FastCGI) containing:

; Custom settings
upload_max_filesize = 1000M
post_max_size = 1000M
memory_limit = 1000M
max_execution_time = 0
max_input_time = 300

However, you'll also need to check the user_ini.filename and user_ini.cache_ttl PHP INI settings as the expected filename might be different on your server and this file is "cached" by default.

Also, your host (GoDaddy) might impose additional restrictions (on shared hosting plans) that cannot be circumvented.

Reference:

  • Related