Fichero htaccess:

El fichero .htaccess (hypertext access) es un archivo que se utiliza dentro de los alojamientos web que utilizan como servidor web Apache. El fichero .htaccess se encuentra oculto (de ahí el punto que le precede) y cuyo acceso a él puede realizarlo a través de ftp.

La utilidad de .htaccess es que le permite mediante reglas aplicar restricciones y múltiples configuraciones que mejorar sus web. Sus principales opciones son habilitar o denegar el acceso a directorios, hacer sus URLs más amigables, realizar redirecciones de dominios, subdominios…, restringir el accesos de IP determinadas, evitar hotlinking, configurar su web con https o modificar el accesos con www o sin www.

El fichero .htaccess está alojado en el raíz del directorio principal de su web (/htdocs) puede acceder a través de FTP con Filezilla

Cambiar parámetros de php a través de htaccess.

Para cambiar parámetros de php a través del fichero .htaccess tiene que seguir la siguiente estructura de directiva:

php_value nombre de la directiva valor(xx)

Modificar memory limit:   php_value memory_limit xxM

Modificar tamaño de archvidos a subir: php_value upload_max_filesize xxM

Modificar tamaño máximo POST HTTP: php_value post_max_size xxM

Modificar tamaño input vars:  php_value max_input_vars xxxx

Redirigir su web sin Certificado (http://) a su web con certificado (https://)

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Redirigir su web sin www a su web con www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^tusitio.com
RewriteRule (.*) http://www.tusitio.com/$1 [R=301,L]

Redirigir su web con www a su web sin www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.tusitio.com [NC]
RewriteRule ^(.*)$ http://tusitio.com/$1 [L,R=301]

Restringir acceso a fichero

<files fichero-a-proteger.php>
order allow,deny
deny from all
</files>

Proteger archivo .htaccess

<Files .htaccess>
Order allow,deny
Deny from all
</Files>

Evitar que roben imágenes()

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?tusitio.com/.*$ [NC]
RewriteRule .(jpg|jpeg|gif|png|bmp)$ - [F]

Restringir Acceso de ip

order allow, deny
deny from 123.4.5.6
deny from 123.45.6.8
deny from 178.0.0.0
allow from all

Activar compresión Gzip

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Aumentar el tamaño máximo de subida de ficheros

php_value upload_max_filesize XXM
php_value post_max_size XXM
No votes yet.
Please wait...