Home › Forum › Problemi Vari con WP › motivi redirect da www a non-www
-
AutorePost
-
-
14 Maggio 2012 alle 12:19 #21645palmerstoneroadPartecipante
Salve,
ho un dubbio: redirect da www a non-www o viceversa? E quali le ragioni della vostra scelta?
Sapreste indicarmi anche come si effettuano tali redirect su wordpress?
grazie!
-
14 Maggio 2012 alle 13:02 #95542TittiModeratore
Non importa quale scegli, l’importante è che poi lo mantieni. Se vuoi saperne di più, Google è il sito adatto per tutte le informazioni.
Il redirect si può fare tramite apposita regola nell’.htaccess
-
15 Maggio 2012 alle 7:50 #95566palmerstoneroadPartecipante
ok grazie!
in realtà ho cercato su google ma non ci sono molte informazioni al riguardo o piuttosto sono molto frammentarie.
Il file .htaccess x wordpress dove lo trovo?
grazie!
-
15 Maggio 2012 alle 7:52 #95567palmerstoneroadPartecipante
e un’altra domanda: sai come scrivere la regola per avere i non-www rediretti a www?
grazie ancora!
-
15 Maggio 2012 alle 9:52 #95569San PietroburgoPartecipante
In molti servizi di host il www (attivato o non) si configura dal pannello di controllo (solitamente e sotto la configurazione generale del dominio; inteso come spazio, quindi non dalla gestione dei DNS), cosଠnon servirà scrivere nulla nel file .htaccess posizionato nella root dell’installazione.
Il www andrebbe tolto quando si utilizzano permalink personalizzati col titolo del post, in questo modo si recuperano 4 caratteri del tutto inutili accorciando le url.. Idem, per la stessa ragione, meglio toglierlo se si usa WordPress in modalità NetWork.
-
15 Maggio 2012 alle 10:10 #95571San PietroburgoPartecipante
Per avere il redirect 301 e stampare tutte le url col www si scrive questo:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ilmiosito.tdl$ [NC]
RewriteRule ^(.*)$ http://www.ilmiosito.tdl/$1 [R=301,L]Per togliere il www invece cosà¬:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ilmiosito.tdl$ [NC]
RewriteRule ^(.*)$ http://ilmiosito.tdl/$1 [R=301,L]Come però detto nel precedente post è meglio gestire questa cosa dal cPanel del servizio di hosting altrimenti, ogni volta che si rigenerano i permalink di WordPress, la regola verrà sovrascritta dalle sue.. E saremo costretti a rifare le modifiche.
-
15 Maggio 2012 alle 13:26 #95592palmerstoneroadPartecipante
ciao grazie per i consigli ma ancora non funziona. Sto usando questo file htaccess:
# BEGIN WordPress
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.miosito.tdl$ [NC]
RewriteRule ^(.*)$ http://miosito.tdl/$1 [R=301,L]
RewriteBase /
# if this request is for “/” or has already been rewritten to WP
RewriteCond $1 ^(index.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 .(gif|jpe?g|png|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ –
# else rewrite the request to WP
RewriteRule . /index.php [L]
# END WordPress
Questa versione lo presa da qui http://www.whiletrue.it/it/blog/wordpress/19-wordpress-un-nuovo-htaccess-per-migliori-prestazioni-e-rispetto-modslotlimit.html perchè ho il sito su tophost. Ho solo aggiunto la parte www -> no www che mi hai consigliato ma come ti dicevo continua a non funzionare.
Cosa c’è che non va?
grazie!
-
15 Maggio 2012 alle 13:53 #95593palmerstoneroadPartecipante
PS ho scelto da www a non-www
-
15 Maggio 2012 alle 19:31 #95608San PietroburgoPartecipante
Quella versione di regole per Apache che hai trovato in un blog di uno pseudo tecnico webmaster italiano sono state copiate da discussioni fatte anni or sono; prima in Russia, poi in Germania e, per finire, approdate sul forum americano webmasterworld, dove scrive un tale (jdMorgan) riconosciuto come uno tra i più preparati del pianeta in certe tematiche.
Il blogger italiota ha solamente copiato e male, senza citare la fonte e, questo è il peggio, senza sapere di cosa sta parlando.
Innanzi tutto non bisogna “mescolare” redirect o direttive; ossia il RedirectMatch da mod_alias con le direttive RewriteRule di mod_rewrite, quando si desidera realmente controllare l’ordine di esecuzione e velocizzare il processo. Le direttive sono elaborate a sua volta da ciascun modulo di Apache, e non strettamente nell’ordine in cui appaiono nel codice del file .htaccess.
Senza prove e test nel server di TopHost non c’è modo di sapere se mod_alias elaborerà per primo e correttamente il file .htaccess, o se mod_rewrite le trattere prima.. Non v’è inoltre alcuna garanzia che questo ordine di esecuzione, quando azzeccato, non cambierà se il server venisse in futuro aggiornato, o se il servizio di hosting modifica la configurazione.
Suggerisco, specie su server italiani come TopHost, Aruba e tanti altri, di non fare le suddette modifiche; modifiche che:
1. Si apportano esclusivamente su servizi dedicati o VPS;
2. vanno comunque testate e perfezionate per la configurazione del proprio server.
Apportare al codice del file .htaccess di un’installazione di WordPress su server condiviso modifiche a casaccio, pensando di velocizzare notevolmente e/o migliorare il corretto funzionamento, potrebbe fare esattamente il contrario e, come ho già detto, anche se oggi vanno bene non è detto che domani funzioneranno ancora.
Dulcis in fundo del copia-incolla senza conoscere la materia di cui si tratta:
Comunque sia il contenuto del file .htaccess che hai postato sbaglia completamente indicazioni su come processare redirect e direttive.
-
15 Maggio 2012 alle 19:53 #95610palmerstoneroadPartecipante
ok grazie per le informazioni.
potresti postarmi le istruzioni x compilare un file htaccess completo per avere redirect da www a non www?
grazie!
-
15 Maggio 2012 alle 20:57 #95612San PietroburgoPartecipante
..potresti postarmi le istruzioni x compilare un file htaccess..
Eeh.. Magari si potesse spiegare con qualche semplice istruzione!
Questo con molta probabilità dovrebbe andare:
RewriteEngine On
RewriteBase /
#
RewriteCond %{HTTP_HOST} !^(www.ilmiosito.tld)?$
RewriteRule ^(.*)$ http://ilmiosito.tld/$1 [R=301,L]
#
# BEGIN WordPress
RewriteCond $1 !^index.php$
RewriteCond $1 !.(gif|jpe?g|png|ico|css|js)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php [L]
# END WordPress
Ovviamente dove ho scritto ilmiosito.tld dovrai scrivere il nome effettivo del tuo dominio e la corretta estensione di questo.
E dove è scritto RewriteBase / se il CMS è in una folder dovrò specificarla, ad esempio: RewriteBase /blog/
Prova se con TopHost è compatibile poiché non ho modo di testarlo non avendo la’ nessuna installazione.
In alternativa si potrebbe fare anche cosଠ(come spiegavo tutto dipende dalla configurazione del server):
RewriteEngine On
RewriteBase /
#
RewriteCond %{HTTP_HOST} !^(www.ilmiosito.tld)?$
RewriteRule ^(.*)$ http://ilmiosito.tld/$1 [R=301,L]
#
# BEGIN WordPress
RewriteCond $1 !^index.php$ [OR]
RewriteCond $1 !.(gif|jpe?g|png|ico|css|js)$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ –
# END WordPress
-
23 Maggio 2012 alle 14:28 #95771palmerstoneroadPartecipante
sono riuscito a settare il tutto tramite pannello hosting e credo che userò la versione non www -> www.
grazie per il supporto!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.