Joomla.it Forum

Joomla! 3 => Joomla! 3 => : eleweb 01 Jun 2016, 11:06:41

: [RISOLTO] web.config aggiungere prefisso www
: eleweb 01 Jun 2016, 11:06:41
Ciao a tutti,
avrei bisogno di una mano, Joomla è su un server Windows e al seguente web.config dovrei aggiungere la regola che se si va sull'url http://miosito.it/nomearticolo/ (http://miosito.it/nomearticolo/) vorrei essere reindirizzato automaticamente sull'url http://www.miosito.it/nomearticolo (http://www.miosotp.it/nomearticolo/)/


Questo per tutti gli url del sito.


Questo è il mio web.config attuale...come posso modificarlo senza esplodere tutto???


:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <location path=".">
   <system.webServer>
       <directoryBrowse enabled="false" />
       <rewrite>
           <rules>
               <rule name="Joomla! Rule 1" stopProcessing="true">
                   <match url="^(.*)$" ignoreCase="false" />
                   <conditions logicalGrouping="MatchAny">
                       <add input="{QUERY_STRING}" pattern="base64_encode[^(]*\([^)]*\)" ignoreCase="false" />
                       <add input="{QUERY_STRING}" pattern="(&gt;|%3C)([^s]*s)+cript.*(&lt;|%3E)" />
                       <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                       <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                   </conditions>
                   <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
               </rule>
               <rule name="Joomla! Rule 2">
                   <match url="(.*)" ignoreCase="false" />
                   <conditions logicalGrouping="MatchAll">
                     <add input="{URL}" pattern="^/index.php" ignoreCase="true" negate="true" />
                     <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                   </conditions>
                   <action type="Rewrite" url="index.php" />
               </rule>
           </rules>
       </rewrite>
   </system.webServer>
   </location>
</configuration>


Ho provato ad aggiungere una riga action così, ma non gli piace:

:
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:1}" redirectType="Permanent" />

: Re:web.config aggiungere prefisso www
: eleweb 01 Jun 2016, 11:31:26
Risolto


ecco il web.config aggiornato, ho dovuto aggiungere una regola!!
Attenzione all'ordine delle rule perchè è importante!!!


:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <location path=".">
   <system.webServer>
       <directoryBrowse enabled="false" />
       <rewrite>
           <rules>
                    <clear />
                    <rule name="Joomla! Rule 1" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                            <add input="{QUERY_STRING}" pattern="base64_encode[^(]*\([^)]*\)" ignoreCase="false" />
                            <add input="{QUERY_STRING}" pattern="(>|%3C)([^s]*s)+cript.*(&lt;|%3E)" />
                            <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                            <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                        </conditions>
                        <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                    </rule>
                    <rule name="Redirect to WWW" enabled="true">
                        <match url="(.*)" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{HTTP_HOST}" pattern="^www\." negate="true" />
                        </conditions>
                        <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent" />
                    </rule>
                    <rule name="Joomla! Rule 2" enabled="true">
                        <match url="(.*)" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{URL}" pattern="^/index.php" ignoreCase="true" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php" />
                    </rule>
           </rules>
       </rewrite>
   </system.webServer>
   </location>
</configuration>
: Re:web.config aggiungere prefisso www
: conti1 01 Jun 2016, 11:33:18
ciao da quando  si fa in quel file?
devi farlo nel .htaccess
li ci metti la regola che vuoi

ma i link postati da te  sono identici solo che uno e www e uno no
tu vuoi  che digitando il tuo web sensa www arrivi sempre con www?
se si la regola se non erro è

:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^tuodominio.com[NC]
RewriteRule ^(.*)$ http://www.tuodominio.com/$1 [L,R=301]

se vuoi indirizzare una pagina  che da errore è
:
#Redirect 301  /riparazione  http://www.tuodominio.com/
: Re:[RISOLTO] web.config aggiungere prefisso www
: eleweb 01 Jun 2016, 11:41:17
Ciao,
il file .htaccess serve sugli hosting linux.
Se l'hosting invece è windows il file di riferimento per queste cose è il web.config (il file .htaccess è ignorato da IIS).


La sostanza è più o meno la stessa che dici tu, ma la sintassi un po' diversa.


Il codice finale non è identico al primo...c'è una regola in più, controlla bene.


Postavo la cosa ai posteri, può sempre venire utile
 :D


Grazie lo stesso per la tua risposta comunque
: Re:[RISOLTO] web.config aggiungere prefisso www
: conti1 01 Jun 2016, 11:47:06
ops
oh dato la risposta  non pensando "anzi davo per scontato che eri linux" anche perche non si  mette joomla su windows avrai probabilmente altri problemi  tutto qui.
: Re:[RISOLTO] web.config aggiungere prefisso www
: eleweb 01 Jun 2016, 12:00:29
Ho diverse installazioni di Joomla sia su linux che su windows, e sinceramente avendo qualche accortezza nei settaggi preferisco windows.
Non ho problemi e più controlli di sicurezza.
Vabbè ma questa è scelta personale.


Ti ringrazio comunque per il consiglio.


Buona giornata e buon lavoro ;)