Linguaggi e spazio web: suggerimenti di configurazione

Una guida con suggerimenti di configurazione e gestione del proprio sito:

Per evitare che al visitatore del proprio sito non rimangano in memoria -Temporary Internet File- nella cache del browser, occorre programmare appositamente le pagine:

Pagine ASP
Inserire il seguente codice:

Response.CacheControl = "no-cache" Response.AddHeader "Pragma", "no-cache" Response.Expires = -1


Pagine HTML
Inserire il seguente codice:
 

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
 

E" possibile creare una estensione di file personalizzata, ad esempio e' possibile creare un file con estensione .link che si comporti esattamente come un file .shtml, sfruttando le possibilità offerte dal file .htaccess.

Per abilitare i file .html ad eseguire le istruzioni SSI, generalmente prerogativa dei file con estensione .shtml aggiungere le seguenti righe al file .htaccess:

AddType text/html .htm
AddType text/x-server-parsed-html .shtml .sht .html
AddHandler server-parsed .shtml .sht .htm


ATTENZIONE: Non e' possibile abilitare estensioni personalizzate in modo che si comportino come .php
in quanto il PHP è configurato come CGI e non come modulo. Di seguito la lista delle associazioni standard fra tipo di file ed estensione:

AddType text/html .html .htm
AddType text/plain .txt
AddType text/richtext .rtx
AddType text/tab-separated-values .tsv
AddType text/x-setext .etx
AddType text/x-server-parsed-html .shtml .sht
AddType application/macbinhex-40 .hqx
AddType application/netalivelink .nel
AddType application/netalive .net
AddType application/news-message-id
AddType application/news-transmission
AddType application/octet-stream .bin .exe
AddType application/oda .oda
AddType application/pdf .pdf
AddType application/postscript .ai .eps .ps
AddType application/remote-printing
AddType application/rtf .rtf
AddType application/slate
AddType application/zip .zip
AddType application/x-mif .mif
AddType application/wita
AddType application/wordperfect5.1
AddType application/x-csh .csh
AddType application/x-dvi .dvi
AddType application/x-hdf .hdf
AddType application/x-latex .latex
AddType application/x-netcdf .nc .cdf
AddType application/x-sh .sh
AddType application/x-tcl .tcl
AddType application/x-tex .tex
AddType application/x-texinfo .texinfo .texi
AddType application/x-troff .t .tr .roff
AddType application/x-troff-man .man
AddType application/x-troff-me .me
AddType application/x-troff-ms .ms
AddType application/x-wais-source .src
AddType application/x-bcpio .bcpio
AddType application/x-cpio .cpio
AddType application/x-gtar .gtar
AddType application/x-shar .shar
AddType application/x-sv4cpio .sv4cpio
AddType application/x-sv4crc .sv4crc
AddType application/x-tar .tar
AddType application/x-ustar .ustar
AddType application/x-director .dcr
AddType application/x-director .dir
AddType application/x-director .dxr
AddType application/x-onlive .sds
AddType application/x-httpd-cgi .cgi
AddType image/gif .gif .GIF
AddType image/ief .ief
AddType image/jpeg .jpeg .jpg .jpe .JPG
AddType image/tiff .tiff .tif
AddType image/x-cmu-raster .ras
AddType image/x-portable-anymap .pnm
AddType image/x-portable-bitmap .pbm
AddType image/x-portable-graymap .pgm
AddType image/x-portable-pixmap .ppm
AddType image/x-rgb .rgb
AddType image/x-xbitmap .xbm
AddType image/x-xpixmap .xpm
AddType image/x-xwindowdump .xwd
AddType audio/basic .au .snd
AddType audio/x-aiff .aif .aiff .aifc
AddType audio/x-wav .wav
AddType audio/x-pn-realaudio .ram
AddType audio/x-midi .mid
AddType video/mpeg .mpeg .mpg .mpe
AddType video/quicktime .qt .mov
AddType video/x-msvideo .avi
AddType video/x-sgi-movie .movie
AddType message/external-body
AddType message/news
AddType message/partial
AddType message/rfc822
AddType multipart/alternative
AddType multipart/appledouble
AddType multipart/digest
AddType multipart/mixed
AddType multipart/parallel
AddType x-world/x-vrml .wrl

E’ possibile reindirizzare i visitatori in base ad alcune condizioni precedentemente impostate, ad esempio il tipo di Browser usato, o il tipo di utente (Rewriteengine), sfruttando le possibilità offerte dal file .htaccess.

Di seguito alcuni esempi di utilizzo, consistenti in linee da inserire nel nostro .htaccess nella root del Dominio:

  1. Codice da utilizzare per reindirizzare in base al browser, da index.php alla pagina prescelta:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
    RewriteRule ^index\.php$ pagina.html
    RewriteCond %{HTTP_USER_AGENT} ^Opera.*
    RewriteRule ^index\.php$ opera.html

     
  2. Codice da utilizzare per reindirizzare le richieste da index.php a www.masterbass.com:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index\.php$ http://www.masterbass.com/$1 [R,L]

     

  3. Codice da utilizzare per reindirizzare le richieste da index.php alla sottocartella go/ nella pagina main.htm:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ go/main.htm

     

  4. Codice da utilizzare per reindirizzare spider, bot e strumenti usati dagli spammer per indicizzare siti spostandoli in un'apposita pagina di scarso benvenuto:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
    RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
    RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
    RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
    RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
    RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
    RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
    RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
    RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
    RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
    RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
    RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
    RewriteCond %{HTTP_USER_AGENT} ^HTTrack [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
    RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
    RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
    RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
    RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
    RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
    RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
    RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
    RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
    RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
    RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
    RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
    RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
    RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
    RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Siphon [OR]
    RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
    RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
    RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
    RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
    RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
    RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Zeus
    RewriteRule ^.*$ http://www.tuodominio.com/pagina_per_gli_spammer.htm [L,R]

Di seguito l’elenco di codici da utilizzare per poter effettuare il Redirect e reindirizzare gli utenti da una pagina (ad esempio iniziale) del proprio sito ad altra, o a una esterna (ad esempio in caso di manutenzione).

Per procedere, inserire i codici di seguito riportati all’interno delle pagine di default del proprio Dominio:

Redirect sfruttando i meta Tag, per pagine HTM, HTML, SHTM
Inserire all'interno dei tag <head> e </head> della propria pagina il codice

<META HTTP-EQUIV=REFRESH CONTENT="1; URL=http://www.arubabusiness.it">

dove 1 è il numero di secondi di attesa e http://www.arubabusiness.it è l'url al quale si viene rimandati accedendo alla pagina che contiene questo codice.

Redirect con Javascript, per pagine HTM, HTML, SHTM
Inserire all'interno dei tag <head> e </head> della propria pagina il codice

<SCRIPT LANGUAGE="Javascript"> <!-- window.location="http://www.arubabusiness.it" //--> </SCRIPT>

Modificare http://www.arubabusiness.it con la propria destinazione (è possibile indicare anche una pagina precisa)

Redirect con PHP, per pagine PHP
Inserire nella pagina solo il codice sotto riportato:

<?
$url = "http://www.arubabusiness.it";
if ($url) {
header("Location: $url");
} else
if($QUERY_STRING) {
header("Location: ".urldecode($QUERY_STRING));
}
else {
echo "Attenzione, l'URL è sbagliato";
}
?>


Modificare http://www.arubabusiness.it con la propria destinazione (è possibile indicare anche una pagina precisa).

Per fare in modo che il Redirect sia di tipo 301 (Moved Permanently) è sufficiente modificare header("Location: $url"); nel seguente modo: header("Location: $url", TRUE, 301);

Nel caso in cui sia necessario limitare la visualizzazione del proprio sito ad alcuni specifici paesi, ad esempio per ragioni di copyright, marchi registrati e diritti d’autore, è possibile evitare che i visitatori di alcuni paesi accedano alla pagina. Per farlo, inserire un semplice codice Javascript all’interno della propria pagina, indipendentemente dal profilo Hosting (Windows o Linux) utilizzato.
 
Di seguito due esempi pratici relativi a due distinti servizi gratuiti:
 

  • Utilizzo del servizio gratuito Geobytes.com
    Per effettuare il Redirect inserire il seguente codice tra i tag <head> e </head>

    <script language="Javascript" src="http://gd.geobytes.com/Gd?pages=IT&ext=html&after=-1"></script>
    <script language="javascript">
    if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode.indexOf('IT')==0)
                   {document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=inserire qui indirizzo'>");}
    </script>

 

  • Utilizzo del servizio gratuito Maxmind.com
    Per effettuare il Redirect inserire il seguente codice tra i tag <head> e </head>

    <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
    <script language="javascript">
    function check_country_code() {
    if(geoip_country_code()=="CN" || geoip_country_code()=="IN" || geoip_country_code()=="TH" || geoip_country_code()=="HK" || geoip_country_code()=="VN")
      window.location = 'http://www.arubabusiness.it'
    else
      return true;}
    </script>