Navigatore:   Home arrow Notizie arrow rewrite .htaccess
Menu principale
Home
Credits
Zend Controller - Note
Notizie
Credits
Music Sense
RED5
Iped
- - - - - - -Mix
Il Tuo IP
Parole crociate - At Cross
1000 Games
Chi e' online
Abbiamo 3 visitatori online
-

rewrite .htaccess Stampa E-mail

 

 Image

 

REWRITE:

 http://cybernetica.it/News/articoli/articolo/index.php?id=6588&revrite-tutorial

IN

 http://www.cybernetica.it/articolo6588/revrite-tutorial.htm

 In questo tutorial riscriveremo un url in modo che il file presente nella nostra vecchia cartella  News/articoli/articolo/ sia rediretto senza perdere pagerank ad un path più simpatico ai motori di ricerca senza dovre spostare un solo file con pochissime regole nell'.htaccess  In this tutorial we'll rewrite an URL in a friendly one so the old file in the old long path folder News/articoli/articolo/ well be forwarded  to a friendly new url without loose page rank  and without move files, but using only fews .htaccess roles
  

 

 


<IfModule mod_rewrite.c>
RewriteEngine On


#Riscrive il dominio senza www facendolo puntare al'URL desiderato

#Rewrite a not www domain pointing to the desired URL 

RewriteCond %{HTTP_HOST} ^cybernetica\.it$ [NC]
RewriteRule ^(.*)$ http://www.cybernetica.it/$1 [R=301,L]

#qui sotto imposto il rewrite di una particolare cartella ramificata di un vecchio sito affinché abbia un URL più simpatico ai motori di ricerca. In particolare mi setto la variabile gow che sarà utilile solo all' .htaccess, fondamentale per evitare che vada in loop sul prossimo  301 che riscriverà i vecchi url già indicizzati su google e probabilmente linkati altrove 

#above the role to setting the rewrite for a long path directory of an old site to give it some more seo friendly URL, like robots want. I set a special var 'gow', that will prevent .htaccess loop by the next 301 role for the rewritin of old indexed and maybe linked  pages.

RewriteRule ^(.*)articolo([0-9]+)\/(.*).htm$ $1/News/articoli/articolo/index.php?gow=1&id=$2&$3

 
# Se nell'url è presente la path qui sotto

#If in Url there's the above path

RewriteCond %{REQUEST_URI} ^(.*)News/articoli/articolo/(.*)$

 

#e se viene passata una variabile 'id' seguita da una variabile senza nome (l'url parlante)

#and if it is get a var 'id'  followed by a no name var (the speaking url)

RewriteCond %{QUERY_STRING} ^(id)=(.*)&(.*)$

#ma non deve esserci la variabile 'gow' = 1 che evita il loop, impostata sopra

#if var  'gow' is != 1, prevent loop

RewriteCond %{QUERY_STRING} !^.*gow=1.*$

#finalmente redirige alla pagina desiderata

#finally rewrite to the desired page 

RewriteRule ^.*$ /articolo%2/%3.htm? [R=301,L]

</IfModule>

 

 

 
< Prec.   Pros. >