Ce este htaccess si de ce este folositor?

postat acum 4 ani de Stefanescu Mihai in categorie iNoob

.htaccess vine de la Hypertext Access, si acest tip de fisiere nu au nume ci incep cu un punct si nu are un nume, deci decat un punct si o extensie. Acesta este un fisier de configurare pentru serverele Apache si este folosit pentru a configura serverul fara a edita fisierele serverului. Acest fisier are continut text si este folosit pentru a controla folderul in care este salvat.Nota: Acest material este menit sa va prezinte puterea htaccessului si nu este un ghid pe care sa-l urmati mot-a-mot.

Nu uitati sa faceti un back-up inainte de a modifica acest fisier!

La ce putem folosi fisierul .htaccess:

  • Blocarea anumitor adrese IP
  • Pagini de eroare custom
  • Crearea de URL-uri curate si “friendly”
  • Redirect
  • Dezactiveaza listarea folderelor
  • Ascunderea extensiilor fisierelor

Abilitatea de a bloca un anumit IP

Blocarea unui singur IP:
order allow, deny
deny from
deny from
deny from
allow from all

Blocarea mai multor adrese de IP:
order allow, deny
deny from 192.168.
deny from 110.1.1.
allow from all

Pagini de eroare custom

  • 400 – Bad request
  • 401 – Authorization Required
  • 403 – Forbidden
  • 404 – File Not Found
  • 500 – Internal Server Error

ErrorDocument 400 /errors/badrequest.htmll
ErrorDocument 401 /errors/authreq.html
ErrorDocument 403 /errors/forbidden.html
ErrorDocument 404 /errors/filenotfound.html
ErrorDocument 500 /errors/internalservererror.html

Dezactivarea listarii folderelor 

Options All -Indexes


ex, de la vechiul-domeniu.ro catre www.noul-domeniu.ro

RewriteEngine on
RewriteCond %{HTTP_HOST} ^vechiul-domeniu.ro
RewriteRule (.*) http://www.noul-domeniu.ro/$1 [R=301,L]

Ascunderea extensiei

De la http://www.siteulmeu.ro/index.html  la  http://www.siteulmeu.ro/index

RewriteEngine on
RewriteRule ^([^/.]+)/?$ $1.html

URL_uri curate si “friendly”

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1

Sunt un tanar programator din Bucuresti ce lucreaza in PHP/Mysql (MySqli/PDO), Laravel, CodeIgniter, MySQL, PostgreSQL, Wordpress, HTML5/CSS3, Sass, Photoshop si multe altele.
Google+ Community Facebook Group
Acest articol a fost mutat de pe vechea platforma.
Pentru orice eroare aparuta la mutare va rog sa ma contactati!

Comentariu postate de Dr. Okun
Frumos tutorial, bravo!
Comentariu postate de Mihai
Comentariu postate de Silviu Udrea
si ajuta mult si la SEO daca sunt facute setarile corect
Comentariu postate de minecraft free download pc la data de 14.05.2019
I've been browsing on-line greater than three hours as of late, but I never found any attention-grabbing article like yours. It's beautiful value enough for me. Personally, if all website owners and bloggers made good content material as you probably did, the net shall be a lot more useful than ever before.
Comentariu postate de download minecraft for free la data de 16.05.2019
Heya! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no back up. Do you have any methods to prevent hackers?
Comentariu postate de minecraft free download pc la data de 17.05.2019
What's Going down i am new to this, I stumbled upon this I've found It absolutely helpful and it has helped me out loads. I am hoping to give a contribution & aid different users like its helped me. Good job.
Comentariu postate de download minecraft for free la data de 18.05.2019
Thank you for some other informative blog. The place else could I get that kind of info written in such a perfect manner? I have a project that I am simply now operating on, and I have been at the glance out for such information.