.htaccess

Bonsoir. Utilité d’avoir un .htaccess à la racine du site ?

Si OUI quels éléments sont conseillés dans celui-ci ? J’imagine que cela n’a rien à voir avec un site « Normal » avec lequel o souhaite optimiser le site.

Merci pour vos conseils.

Bonsoir,
Il me semble que oui, il faut mettre les instructions pour que les moteurs de recherche n’indécent pas les pages.

Bonjour cmaconception, ça c’est dans le fichier robot non ? (enfin moi c’est là que j’ai mis les information de non indexation)

Oui mais il me semble que dans le htaccess, on peut verrouiller l’accès aux fichiers. A confirmer car cela fait un moment que je n’ai pas travaillé sur les miens.

Bonjour,
La discussion ne sert à rien si nous ne savons pas comment est installé votre Dolibarr !
Les fichiers robots.txt sont prévu et installés en même temps que Dolibarr.
Par contre un htaccess peut être utile pour interdire l’accès au dossier documents par exemple.

Expliquez l’arborescence de votre installation et on y regarde…
@+

Bonsoir. Elle ne sert à rien ? Si je vous pose la question c’est que pour moi surement elle peut servir à quelque chose.

Pour être plus clair. Je ne recherche pas à « Interdir un quelconque accès », MAIS savoir si comme pour un site internet traditionnel, il est possible, souhaitable/ou pas, d’essayer d’optimiser Apache via le .htaccess pour DONC optimiser Dolibarr. (Cache navigateur/compression/redirection…)

Mon arborescence : /home/web160gestiondol/public_html/htdocs

J’ai inséré mon .htaccess dans /public_html/htdocs

Le contenu de mon .htaccess :

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

# Specify a Default Charset
AddDefaultCharset utf-8

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

   RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
   RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Le cache control
<IfModule mod_headers.c>
  # Mise en cache des images et autres fichier statiques pour un mois
  <FilesMatch ".(ico|jpe?g|png|webp|gif|swf|flv|css|js|gz|pdf|svg+xml|svg)$">
   Header set Cache-Control "max-age=2592000"
  </FilesMatch>

  # Mise en cache du html et xml pour 12 heures
  <filesMatch ".(html|htm|xml)$">
   Header set Cache-Control "max-age=43200"
  </filesMatch>

  # Désactive la mise en cache pour les fichier PHP et CGI
  <FilesMatch ".(php|cgi)$">
   Header unset Cache-Control
  </FilesMatch>
</IfModule>

# Les expires headers 
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 7200 seconds"
  AddType image/x-icon .ico
  AddType application/x-font-woff .woff
  AddType application/x-font-woff2 .woff2
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/ico "access plus 1 year"
  ExpiresByType image/jpg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/icon "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType text/html "access plus 7200 seconds"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/xhtml+xml "access plus 7200 seconds"
  ExpiresByType application/x-javascript "access plus 1 year"
  ExpiresByType application/x-shockwave-flash "access plus 1 year"
  ExpiresByType application/x-font-woff "access plus 1 year"
  ExpiresByType application/x-font-woff2 "access plus 1 year"
</IfModule>

# Disable server signature (Security)
ServerSignature Off
Header unset Etag
FileETag none

# Increase cookie security (Security)
<IfModule php5_module>
	php_value session.cookie_httponly true
</IfModule>

# HTTP Response Headers
Header always append X-Frame-Options SAMEORIGIN
Header set X-XSS-Protection 1;mode=block
Header set X-Content-Type-Options nosniff

# Webfont access
<IfModule mod_headers.c>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
		Header set Access-Control-Allow-Origin "*"
	</FilesMatch>
</IfModule>

# Force latest IE rendering engine
<IfModule mod_headers.c>
	Header set X-UA-Compatible "IE=Edge,chrome=1"
		# mod_headers can't match by content-type, but we don't want to this header on everything
		<FilesMatch "\.(js|css|gif|png|jpeg|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
			Header unset X-UA-Compatible
		</FilesMatch>
</IfModule>

# Instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>

# CORS-enabled images (@crossorigin)
<IfModule mod_setenvif.c>
	<IfModule mod_headers.c>
		<FilesMatch "\.(gif|png|jpeg|svg|svgz|ico|webp)$">
			SetEnvIf Origin ":" IS_CORS
			Header set Access-Control-Allow-Origin "*" env=IS_CORS
		</FilesMatch>
	</IfModule>
</IfModule>

<Files 403.shtml>
order allow,deny
allow from all
</Files>

# KILL THEM ETAGS
Header unset ETag
FileETag none

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php56 .php .phtml
# php -- END cPanel-generated handler, do not edit

Ou est-ce en vain ?
Merci pour le temps consacré.

Bonsoir,

Oui comme tous les scripts PHP il peut être optimisé par les mécanismes pre-cites mais pour avoir déja fait certains tests les gains sont extrêmement minimes. En revanche je vous conseille de vous orienter vers de l OPCODE qui améliore plus les performances.

Bonne soirée

Merci d’avoir pris le temps de répondre.

j’ai rajouté la compression sur le htaccess que je n’avais pas mis. Ensuite sur le serveur, concernant Apache, ce n’est pas OPCODE que j’ai mais j’ai un autre cache d’installé. Entre temps j’ai trouvé ce sujet : https://wiki.dolibarr.org/index.php/FAQ_Améliorer_les_performances et finalement je suis proche de ce qui est prescrit.

La seule chose que je n’ai pas essayée c’est de rajouter notre Dolibarr sur le CDN.

Encore merci :slight_smile:

Pour augmenter la taille des fichiers téléchargéable on peut également ajouter ceci au .htaccess:

php_value post_max_size 20M
php_value upload_max_filesize 20M

Ou bien l’ajouter au php.ini:

post_max_size=20M
upload_max_filesize=20M

Les 2 lignes sont nécessaires cas le téléversement passe par une requête POST.