Htaccess

De MochilaWiki
Ir para navegaçãoIr para pesquisar

ruby -e "puts 'quijaua:' + 'Ooj3aequ9lah'.crypt('md5')" >> /etc/nginx/htpasswd

perl -le 'print crypt("password", "salt")'

$ php -a php > echo crypt('asdf', base64_encode('asdf')); YXWM35gonN/VU

$ echo 'tobias:YXWM35gonN/VU' >> /etc/nginx/htpasswd


htpasswd -c -d /etc/nginx/htpasswd asalnikov


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