Crear archivo .htaccess

Saltar a: navegación, buscar

Esta página necesita una revisión. Por favor, revísela y quite la plantilla {{Revisar}} cuando haya terminado.

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Moodle 1.9

If you are setting-up Moodle on a webhost, or don't have access to httpd.conf or php.ini on your server, or you have Moodle on a server with other applications that require different settings, then don't worry, you can often override the default settings. This only works on Apache servers and only when Overrides have been allowed in the main Apache configuration. Moodle is supplied with a .htaccess file which you can use, or you can create your own file manually.

Find a .htaccess file

Use the default .htaccess file. The easiest thing to do is just copy the sample file from moodle/lib/htaccess and edit it to suit your needs. It contains further instructions. For example, in a Unix shell:

cd moodle
cp moodle/lib/htaccess .htaccess

Create a .htaccess file

Alternatively to modifying a Moodle file, you can create your own file called .htaccess in Moodle's main directory that contains lines like the following.

DirectoryIndex index.php index.html index.htm
php_value memory_limit 40M (adjust to your version of Moodle)
php_flag magic_quotes_gpc 1
php_flag magic_quotes_runtime 0
php_flag file_uploads 1
php_flag session.auto_start 0
php_flag session.bug_compat_warn 0
If you have Apache version 2 installed, add these lines:
<IfDefine APACHE2>
    AcceptPathInfo on
Otherwise add this single line:
AcceptPathInfo on
Optionally, you can also do things like define the maximum size for uploaded files, etc by adding these lines:
LimitRequestBody 0
php_value upload_max_filesize 2M
php_value post_max_size 2M

Increase upload file size

The Apache default value given in these lines is usually 2Meg. You may want to change this at a later date to allow uploading of larger files.

.htaccess alternatives

Some shared hosts do not allow .htaccess files. In this case, it may be necessary to place a php.ini file within each sub-directory of the site. To do this, you use your editor to create a php.ini file in the main Directorio Moodle del sitio Moodle and later copy it to all sub-directories.

The syntax for the php.ini file is different than the one used in .htaccess - you do not use the php_value and php_flag prefixes. See the example below:

upload_max_filesize = 2M
post_max_size = 2M
After creating the php.ini file with all of the statements you need, run the script or copy php.ini manually to all sub-directories.
  • Some shared hosts use suPHP, which requires a slightly different configuration. If everything else fails, try creating the following two files and uploading to your moodle root directory
php.ini (sample):
register_globals = 0
display_errors = 0
.htaccess (sample):
suPHP_ConfigPath /home/cPanelName/public_html/moodle

Change the above path to the actual path to your moodle install.

  • Note: Use a .htaccess file only as a last resort as it can have an impact on the performance of your Moodle site and cause pages to load slowly on your browser.

See also