Mudanças entre as edições de "Htaccess"

De MochilaWiki
Ir para navegaçãoIr para pesquisar
Linha 1: Linha 1:
Instalei o apache
+
== controle de acesso por senha/usuario ==
# apt-get install apache2
 
  
 
na linha 12 do arquivo /etc/apache2/sites-enabled/000-default altere de
 
na linha 12 do arquivo /etc/apache2/sites-enabled/000-default altere de
Linha 45: Linha 44:
 
== valores para o PHP ==
 
== valores para o PHP ==
  
  <?
+
  php_value      default_charset UTF-8
  setlocale(LC_ALL, "pt_BR", "ptb");
 
?>
 
 
 
 
 
PHP_VALUE mbstring.internal_encoding UTF-8
 
PHP_VALUE default_charset UTF-8
 
PHP_VALUE mbstring.http_output UTF-8
 
PHP_VALUE mbstring.encoding_translation On
 
PHP_VALUE mbstring.detect_order UTF-8
 
PHP_VALUE mbstring.func_overload 7
 
 
 
php_value      upload_max_filesize    5M
 
php_value      post_max_size          6M
 
php_value      memory_limit            64M
 
 
  php_flag        display_errors  Off
 
  php_flag        display_errors  Off
 +
php_flag        engine off
 +
php_value      error_log      logs/errors
 
  php_flag        log_errors      On
 
  php_flag        log_errors      On
  php_value      error_log      logs/errors
+
  php_value      max_execution_time 600
  php_value      zlib.output_compression        0
+
  php_value      max_input_time 600
 
  php_value      magic_quotes_gpc                0
 
  php_value      magic_quotes_gpc                0
  php_value      zend.ze1_compatibility_mode    0
+
  php_value      mbstring.internal_encoding UTF-8
 +
php_value      mbstring.http_output UTF-8
 +
php_value      mbstring.encoding_translation On
 +
php_value      mbstring.detect_order UTF-8
 +
php_value      mbstring.func_overload 7
 +
php_value      mbstring.func_overload  0
 +
php_value      memory_limit            64M
 +
php_value      post_max_size          6M
 
  php_value      suhosin.session.encrypt        Off
 
  php_value      suhosin.session.encrypt        Off
 
  php_value      session.auto_start      0
 
  php_value      session.auto_start      0
Linha 71: Linha 65:
 
  php_value      session.gc_divisor      500
 
  php_value      session.gc_divisor      500
 
  php_value      session.gc_probability  1
 
  php_value      session.gc_probability  1
  php_value      mbstring.func_overload  0
+
  php_value      upload_max_filesize    5M
  php_value      max_execution_time 600
+
  php_value      zend.ze1_compatibility_mode    0
  php_value      max_input_time 600
+
  php_value      zlib.output_compression        0
php_flag        engine off
 
 
 
  
 +
<?
 +
  setlocale(LC_ALL, "pt_BR", "ptb");
 +
?>
  
  

Edição das 16h44min de 10 de abril de 2010

controle de acesso por senha/usuario

na linha 12 do arquivo /etc/apache2/sites-enabled/000-default altere de

AllowOverride None

por

AllowOverride All

reinicie o apache

# /etc/init.d/apache2 restart

Para permitir o acesso de uma pasta somente com senha crie o arquivo .htaccess dentro da pasta com o conteudo:

AuthName bantonilds
AuthType Basic
AuthUserFile "/opt/senhas.txt"
require user banto

em "/opt/senhas.txt" ficara os dados de usuario e senha que o apache ira consultar. Para gerar esses dados use o comando:

# htpasswd -c /opt/senhas.txt banto
New password:
Re-type new password:
Adding password for user banto

Para ter mais de um usuario troque em .htaccess a linha

require user banto

por

require valid-user

e para inserir os proximos usuarios use:

# htpasswd /opt/senhas.txt banto

para negar acesso a uma pasta, dentro dela crio o arquivo .htaccess com o conteudo:

Deny from all

referencias:

proibindo ip

order allow,deny
deny from 192.168.1.1
deny from 10.0.2.2
allow from all

valores para o PHP

php_value       default_charset UTF-8
php_flag        display_errors  Off
php_flag        engine off
php_value       error_log       logs/errors
php_flag        log_errors      On
php_value       max_execution_time 600
php_value       max_input_time 600
php_value       magic_quotes_gpc                0
php_value       mbstring.internal_encoding UTF-8
php_value       mbstring.http_output UTF-8
php_value       mbstring.encoding_translation On
php_value       mbstring.detect_order UTF-8
php_value       mbstring.func_overload 7
php_value       mbstring.func_overload  0
php_value       memory_limit            64M
php_value       post_max_size           6M
php_value       suhosin.session.encrypt         Off
php_value       session.auto_start      0
php_value       session.gc_maxlifetime  21600
php_value       session.gc_divisor      500
php_value       session.gc_probability  1
php_value       upload_max_filesize     5M
php_value       zend.ze1_compatibility_mode     0
php_value       zlib.output_compression         0
<?
 setlocale(LC_ALL, "pt_BR", "ptb");
?>


Remover extensão da url

para php

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

para html

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]

fonte: http://bestdesigns.co.in/blog/remove-extensions-url


redirecionar página antiga

redirect 301 /old-file-name.htm   http://www.domain.com/new-file-name.htm