Come ripristinare il file htaccess in caso di errore

In caso di messaggi d’errore (4xx) o problemi di reindirizzamento (3xx), può essere opportuno ripristinare il file .htaccess predefinito fornito con il CMS in uso. Di seguito una breve lista dei file .htaccess di default forniti per i CMS più popolari e maggiormente utilizzati.
WordPress
Esistono tre tipologie di file .htaccess relative a diverse varianti di WordPress. La prima è la regola basic nel caso in cui venga utilizzato un unico sito, le altre due riguardano le versioni multisite, una configurato con domini in sottocartelle, che utilizza la regola “subdirectory”, l’altra che usa la regola “subdomain” se i domini aggiuntivi sono in sottodomini

  • WordPress Basic

RewriteEngine On

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /

RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

  • WordPress Multisite (Subfolder)

RewriteEngine On

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /

RewriteRule ^index\.php$ – [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ – [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

RewriteRule . index.php [L]

  • WordPress Multisite (Subdomain)

RewriteEngine On

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /

RewriteRule ^index\.php$ – [L]

RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ – [L]

RewriteRule ^(wp-(content|admin|includes).*) $1 [L]

RewriteRule ^(.*\.php)$ $1 [L]

RewriteRule . index.php [L]

 

Joomla

IndexIgnore *

Header always set X-Content-Type-Options “nosniff”

Options +FollowSymlinks

Options -Indexes

<FilesMatch “\.svg$”>

Header always set Content-Security-Policy “script-src ‘none'”

RewriteEngine On

RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]

RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]

RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

RewriteRule .* index.php [F]

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} !^/index\.php

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php [L]

 

Drupal 7

<FilesMatch “\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$”>

Require all denied

Order allow,deny

Options -Indexes

Options +FollowSymLinks

ErrorDocument 404 /index.php

DirectoryIndex index.php index.html index.htm

php_flag magic_quotes_gpc off

php_flag magic_quotes_sybase off

php_flag register_globals off

php_flag session.auto_start off

php_value mbstring.http_input pass

php_value mbstring.http_output pass

php_flag mbstring.encoding_translation off

ExpiresActive On

ExpiresDefault A1209600

ExpiresActive Off

RewriteEngine on

RewriteRule ^ – [E=protossl]

RewriteCond %{HTTPS} on

RewriteRule ^ – [E=protossl:s]

RewriteRule ^ – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteRule “/\.|^\.(?!well-known/)” – [F]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !=/favicon.ico

RewriteRule ^ index.php [L]

RewriteCond %{HTTP:Accept-encoding} gzip

RewriteCond %{REQUEST_FILENAME}\.gz -s

RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

RewriteCond %{HTTP:Accept-encoding} gzip

RewriteCond %{REQUEST_FILENAME}\.gz -s

RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

RewriteRule \.css\.gz$ – [T=text/css,E=no-gzip:1]

RewriteRule \.js\.gz$ – [T=text/javascript,E=no-gzip:1]

<FilesMatch “(\.js\.gz|\.css\.gz)$”>

Header set Content-Encoding gzip

Header append Vary Accept-Encoding

Header always set X-Content-Type-Options nosniff

 

Drupal 9

<FilesMatch “\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)

(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$”>

Require all denied

Order allow,deny

Options -Indexes

DirectoryIndex index.php index.html index.htm

AddType image/svg+xml svg svgz

AddEncoding gzip svgz

php_value assert.active 0

ExpiresActive On

ExpiresDefault A1209600

ExpiresActive Off

FallbackResource /index.php

RewriteEngine on

RewriteRule ^ – [E=protossl]

RewriteCond %{HTTPS} on

RewriteRule ^ – [E=protossl:s]

RewriteRule ^ – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteRule “/\.|^\.(?!well-known/)” – [F]

RewriteCond %{REQUEST_URI} ^(.*)?/(install\.php) [OR]

RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild\.php)

RewriteCond %{REQUEST_URI} !core

RewriteRule ^ %1/core/%2 [L,QSA,R=301]

RewriteRule ^core/install\.php core/install.php?rewrite=ok [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !=/favicon.ico

RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$

RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?\.php

RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics\.php$

RewriteRule “^(.+/.*|autoload)\.php($|/)” – [F]

RewriteCond %{HTTP:Accept-encoding} gzip

RewriteCond %{REQUEST_FILENAME}\.gz -s

RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

RewriteCond %{HTTP:Accept-encoding} gzip

RewriteCond %{REQUEST_FILENAME}\.gz -s

RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

RewriteRule \.css\.gz$ – [T=text/css,E=no-gzip:1,E=no-brotli:1]

RewriteRule \.js\.gz$ – [T=text/javascript,E=no-gzip:1,E=no-brotli:1]

<FilesMatch “(\.js\.gz|\.css\.gz)$”>

Header set Content-Encoding gzip

Header append Vary Accept-Encoding

Header always set X-Content-Type-Options nosniff

RequestHeader unset Proxy

 

PrestaShop

SetEnv HTTP_MOD_REWRITE On

RewriteEngine on

RewriteRule . – [E=REWRITEBASE:/]

RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]

RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]

RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]

RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]

RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]

RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]

RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]

RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-

9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$

9$10.jpg [L]

RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %

{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]

RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]

RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ – [NC,L]

RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]

AddType application/vnd.ms-fontobject .eot

AddType font/ttf .ttf

AddType font/otf .otf

AddType font/woff2 .woff2

AddType application/x-font-woff .woff

<FilesMatch “\.(ttf|ttc|otf|eot|woff|woff2|svg)$”>

Header set Access-Control-Allow-Origin “*”

ErrorDocument 404 /index.php?controller=404

 

Magento

DirectoryIndex index.php

php_value memory_limit 512M

php_value max_execution_time 18000

php_flag magic_quotes_gpc off

php_flag session.auto_start off

php_flag suhosin.session.cryptua off

php_flag zend.ze1_compatibility_mode Off

SecFilterEngine Off

SecFilterScanPOST Off

SSLOptions StdEnvVars

Options +FollowSymLinks

RewriteEngine on

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php [L]

AddDefaultCharset Off

ExpiresDefault “access plus 1 year”

Order allow,deny

Allow from all

UI Designer




Articoli Correlati