Disabilita SOLO il completamento automatico dell'URL, non l'intero sistema URL canonico
-
-
questa caratteristica diindovinare l'URLprincipalepasticcia anche congli strumenti SEOe SEO !!this core URL guessing feature also messes with SEO and SEO tools !!
- 0
- 2018-08-28
- Mau
-
2 risposta
- voti
-
- 2014-05-20
Ok,dopo aver cercato unpo 'dipiù hofinalmentetrovato una risposta allamia domandanascostain un commento di questoticket di richiesta difunzionalità: https://core.trac.wordpress.org/ticket/16557 L'utentenacin ha suggerito di utilizzare questo codice:
function remove_redirect_guess_404_permalink( $redirect_url ) { if ( is_404() ) return false; return $redirect_url; } add_filter( 'redirect_canonical', 'remove_redirect_guess_404_permalink' );
Se lo aggiungi a unnuovofilephp delplugin (adesempioin wp-content/plugins/disable-url-autocorrect-guessing.php) avrai unbelplugin chepuoi attivareper disabilitare la correzione automatica di Wordpress "indovinare ".
Per risparmiarti lafatica,l'hofattoe ho consegnatoilmioplugin su Wordpress.org. Una voltaesaminato lì,dovrestiesserein grado di scaricarlo qui: https://wordpress.org/plugins/disable-url-autocorrect-guessing/
Sebbene questa sia una soluzionefunzionante,il codice suggerito èin qualchemodo un hack. Dopo la richiesta dellafunzionein https://core.trac.wordpress.org/ticket/16557 èeffettivamenteimplementato,ci saranno soluzionimiglioriper questo,oltre a un controllomoltomigliore su comeeseguire leipotesi.
Okay, after searching a bit more I finally found an answer to my own question hidden in a comment of this feature request ticket: https://core.trac.wordpress.org/ticket/16557 The user nacin suggested to use this code:
function remove_redirect_guess_404_permalink( $redirect_url ) { if ( is_404() ) return false; return $redirect_url; } add_filter( 'redirect_canonical', 'remove_redirect_guess_404_permalink' );
If you add this to a new plugin php file (for example in wp-content/plugins/disable-url-autocorrect-guessing.php) you'll have a nice plugin that you can activate to disable Wordpress' autocorrect "guessing" feature.
In order to save you the trouble I actually did this and handed in my plugin at Wordpress.org. Once it gets reviewed there, you should be able to download it here: https://wordpress.org/plugins/disable-url-autocorrect-guessing/
While this is a working solution, the suggested code is somewhat of a hack. Once the feature request in https://core.trac.wordpress.org/ticket/16557 is actually implemented, there will be way better solutions for this as well as much better control over how the guessing should actually be performed.
-
Vorreipoter votare questotre volte ...Wish I could upvote this thrice...
- 0
- 2015-08-07
- KalenGi
-
Mi haispiratoperché avevoproblemi conil reindirizzamentopaginato.Avevointenzione di rimuovere "remove_filter ()".Ma ora aggirando soloil caso specificoin cui hoproblemi.Nel caso qualcunofosseinteressato almioproblema: https://wordpress.stackexchange.com/questions/307670/custom-pagination-structureInspired me as I was having issue in paged redirection. I was planning to `remove_filter()`. But now bypassing only specific case where I am having trouble. Just in-case anyone interested about my issue: https://wordpress.stackexchange.com/questions/307670/custom-pagination-structure
- 0
- 2018-07-04
- Parixit
-
nonfunzionapiùin v5 +no longer works in v5+
- 0
- 2019-06-25
- nodws
-
@nodws: a cosati riferisci?Sto usandoilmioplugin con lo snippet di codice su 5.2.2e funziona ancorabene.@nodws: What are you referring to? I'm using my plugin with the code snippet on 5.2.2 and it still works fine.
- 0
- 2019-06-26
- Hauke P.
-
Oh,era un conflitto coni reindirizzamenti di YOASTOh it was a conflict with YOAST's redirects
- 0
- 2019-06-27
- nodws
-
- 2014-05-20
Purtroppo
redirect_canonical()
contienepiù di 400 righe di codice (econtinua a crescere di rilascioin rilascio),chenon èparticolarmente strutturatoperessere controllato dallo scopo.Ètutto oniente affare chenonpuòessere configuratoin modoflessibile.Dalpunto di vistapratico letuemigliori opzioni sono:
- Gestionemanuale del reindirizzamento,in
template_redirect
. - Prevenireil reindirizzamento come hook
redirect_canonical
seiltarget che è venutofuorinon è desiderabile.
Inentrambii casi dovrai sviluppare la logica di cosaesattamente rendeil reindirizzamentoindesiderato.
Unfortunately
redirect_canonical()
is 400+ lines of code (and keeps growing from release to release), which is not particularly structured to be controlled by purpose. It's all or nothing deal that cannot be flexibly configured.From practical point of view your best options are:
- Handling redirect manually, at
template_redirect
. - Preventing redirect as
redirect_canonical
hook if target it came up with is not desirable.
In either case you'll have to develop out the logic of what exactly makes undesirable redirect.
-
Eh,questo èinaspettatamentemolto sfortunato.:-( Lamia definizione di reindirizzamentoindesiderato èpiuttosto semplice: ogni URL chenonpuòessere risoltoesattamentein ** un **target (mamultiplo onessuno) èindesiderabilee dovrebbe risultarein un 404.Huh, that is unexpectedly very unfortunate. :-( My definition of a undesirable redirect is pretty simple: Every URL that cannot be resolved to exactly **one** target (but multiple or none) is undesirable and should result in a 404.
- 0
- 2014-05-20
- Hauke P.
-
@HaukeP.la logica responsabile di ciòfaparte di [`redirect_guess_404_permalink ()`] (http://queryposts.com/function/redirect_guess_404_permalink/)e nonfatale distinzione,prende solo laprima corrispondenza che SQLproduce :(@HaukeP. logic responsible for that is part of [`redirect_guess_404_permalink()`](http://queryposts.com/function/redirect_guess_404_permalink/) and it doesn't make such distinction, just takes the first match SQL produces :(
- 0
- 2014-05-20
- Rarst
-
In realtà hotrovato una soluzione da solo: http://wordpress.stackexchange.com/a/144970/51898Actually I did find a solution on my own: http://wordpress.stackexchange.com/a/144970/51898
- 0
- 2014-05-20
- Hauke P.
-
@HaukeP.Ti hofrainteso unpo 'su "esattamente un obiettivo",perché alcuni casi di corrispondenzafuzzytecnicamente si risolverannoin una sola corrispondenza,manon è come sbarazzarsi di cose sfocatein generale :)@HaukeP. I misunderstood you a bit about "exactly one target", because some cases of fuzzy matching will technically resolve to only one match, but it's not the same as getting rid of fuzzy stuff in general :)
- 0
- 2014-05-20
- Rarst
-
Già,in realtàmentre scrivevoilmio ultimo commentomi sonofermato un secondo apensarci ancoraperpaura diesserefrainteso.:) Quindi sembra che avrei dovuto scrivereilmio commento (e domanda)in modopiùpreciso,dopotutto.Yeah, actually while writing my last comment I stopped for a second to think about again in the fear of being misunderstood. :) So it looks like I should have written my comment (and question) more precise after all.
- 0
- 2014-05-20
- Hauke P.
Ho unblog con diversepaginein alcune categorie "progetti" strutturate/denominatein questomodo:
Quando un utenteimmette URL come http://myblog.com/project o anche http://myblog.com/proje viene reindirizzato alpagina /projects/project-2012 . (Con un 301 spostatoin modopermanente!)
Anche se voglio che wordpresstrasformigli URLin unapagina chiaramente definita (adesempio,come http://myblog.com/?p=123 )nelmodulo canonico,desidero disabilitare soloil completamento automatico dell'URLpergli URL "non chiari" chepotrebberopuntare apiùpagine.
Lamia domanda è: comepossofarlo?
Ho anchefatto delle ricerche ...
La risposta accettata alla domanda Disabilitail completamento automatico dell'URL di Wordpress disabilita l'intero sistema URL canonico. Questonon è accettabileper me.
Circa quattro annifa è apparso qualcosa di simile sulbugtracker di Wordpress: https://core.trac.wordpress.org/ticket/8948 Anche se alcunebuone soluzioni (come offrire unapagina "Non abbiamotrovatoiltuo URL. Ma staviforse cercando una delle seguentipagine?") sono state discusse lì,ilticket è stato chiuso allafine.
EDIT: in realtà c'è unticketpiù recente su https ://core.trac.wordpress.org/ticket/16557 che copreesattamente ciò di cui hobisogno. Sembraesseremirato alla versione 4.0. Ei commenti delticket contengono anche una soluzione (vedi sotto).