Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules Aggiungi barra alla fine della Fine del URL con. Htaccess Riscrivere Regole

For a website that has URLs that end with a slash (/), it’sa good practice to ensure that all url links been parsed by the web server ended with trailing slash, even if visitors forget to enter the ending slash. Per un sito web con gli URL che terminano con una barra (/), è una buona pratica per garantire che tutti i collegamenti url stati analizzati dal server web si è conclusa con barra finale, anche se i visitatori dimenticare di inserire la fine barra. This avoid visitors been served with 404 Page Not Found or Page Cannot be Displayed error as some web servers treat links without trailing slash as a file name instead of directory, and thus unable to locate the documents. Visitatori evitare questo stato servito con 404 Pagina non trovata o Impossibile visualizzare la pagina di errore, dato che alcuni server web link trattare senza barra finale, come un nome di file invece di directory, e quindi in grado di individuare i documenti. It also eliminates the possibility that both pages with same content, one with slash at the end and another without, been viewed by search engines as duplicate content. Ha inoltre elimina la possibilità che entrambe le pagine con lo stesso contenuto, con uno slash alla fine e senza un altro, sono stati visti dai motori di ricerca come duplicati.

As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/. A titolo di esempio, a tutti gli hit http://www.mydigitallife.info/contact dovrebbe essere reindirizzamento al http://www.mydigitallife.info/contact/.

Most web server, including the popular Apache HTTPD web server supports mod_rewrite module where rules can be set in .htaccess file in order to redirect to add trailing slash to the URLs that does not already have one. La maggior parte dei server web, tra cui il popolare httpd Apache web server supporta modulo mod_rewrite in cui regole possono essere impostate in. Htaccess file per aggiungere reindirizza alla barra alla fine di URL che non dispongono già di uno.

The following code can be put in .htaccess to redirect URL without trailing slash to URL with trailing slash: Il codice riportato di seguito possono essere messi in. Htaccess per reindirizzare URL senza barra alla fine di URL con barra finale:

RewriteEngine On RewriteEngine su
RewriteBase / RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond% (REQUEST_FILENAME)! F -
RewriteCond %{REQUEST_URI} !index.php RewriteCond% (REQUEST_URI)! Index.php
RewriteCond %{REQUEST_URI} !(.*)/$ RewriteCond% (REQUEST_URI) !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] RewriteRule ^(.*)$ http://domain.com/ $ 1 / [L, R = 301]

or o

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond% (REQUEST_FILENAME)! F -
RewriteCond %{REQUEST_URI} !\..+$ RewriteCond% (REQUEST_URI)! \ .. + $
RewriteCond %{REQUEST_URI} !/$ RewriteCond% (REQUEST_URI)! / $
RewriteRule (.*) http://www.mydigitallife.info/$1/ [R=301,L] RewriteRule (.*) http://www.mydigitallife.info/ $ 1 / [R = 301, L]

or o

RewriteEngine On RewriteEngine su
RewriteBase / RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L] RewriteRule ^ ([a-zA-Z0-9 ]+)/$ / $ 1 [L]
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([a-zA-Z0-9]+) RewriteCond% () THE_REQUEST ^ [AZ] (3,9) \ / ([a-zA-Z0-9] +)
RewriteRule ^([a-zA-Z0-9]+)$ /%1/? RewriteRule ^ ([a-zA-Z0-9] +) $ /% 1 /? [R=301,L] [R = 301, L]

In you’re using CMS or blog such as Wordpress that allows custom URL structure for permalinks, especially for search engine optimization (SEO), the above code should come before the block of rewrite conditions and rules for URL customization for the CMS or blog platform. In stai utilizzando CMS o blog come Wordpress che consente URL personalizzato per permalink struttura, in particolare per l'ottimizzazione dei motori di ricerca (SEO), il codice sopra dovrebbero venire prima del blocco di riscrivere le condizioni e le regole di URL di personalizzazione per il CMS o blog piattaforma .

Brief explaination of the rewrite code to add trailing slash to URL Breve explaination di riscrivere il codice per aggiungere barra alla fine di URL

RewriteEngine On - This line enables the runtime rewriting engine based on mod_rewrite module of Apache. RewriteEngine su - Questa linea consente il motore runtime di riscrittura basate su modulo mod_rewrite di Apache.

RewriteBase / - This line sets the current page root directory as base URL for per-directory rewrites. RewriteBase / - Questa linea fissa la pagina corrente come root directory URL di base per per-directory riscrive.

RewriteCond %{REQUEST_FILENAME} !-f - This line excludes all URLs pointing to existed files from been added with trailing slash again. RewriteCond% (REQUEST_FILENAME)!-F - Questa linea esclude tutti gli URL che punta al file da esistevano stato aggiunto con barra di nuovo. Directories cannot be excluded as this would exclude the rewrite behavior for existing directories. Directory non può essere esclusa in quanto ciò esclude la riscrittura comportamento per le directory esistenti.

RewriteCond %{REQUEST_URI} !index.php - This line is optional, and will excludes a sample URL (in this case, index.php) that users do not want it to be rewritten. RewriteCond% (REQUEST_URI)! Index.php - Questa linea è facoltativa, e si esclude una URL di esempio (in questo caso, index.php) che gli utenti non ne vogliono sapere di essere riscritti. Remove this line if not necessary. Rimuovere questa linea se non necessario.

RewriteCond %{REQUEST_URI} !\..+$ - Specify that the URL does not contain any . RewriteCond% (REQUEST_URI)! \ .. + $ - Specifica che l'URL non contiene alcuna. (dot) to exclude reference to file. (punto) di escludere riferimento al file.

RewriteCond %{REQUEST_URI} !(.*)/$ - This line determines which URL doesn’t contain a trailing slash RewriteCond% (REQUEST_URI) !(.*)/$ - Questa linea che determina URL non contiene una barra

RewriteRule ^(.*)$ http://www.domain.com/$1/ [L,R=301] - This line process URL without trailing slash that has passed conditions set above, by appending a trailing slash and then redirect with 301 or permanent redirect status to the new URL. RewriteRule ^(.*)$ http://www.domain.com/ $ 1 / [L, R = 301] - Questa linea processo URL senza barra finale che ha superato le condizioni di cui sopra, aggiungendo una barra e quindi reindirizzare con 301 o permanente stato di reindirizzare il nuovo URL. L mean this is the last line to process and the rewrite process can be terminated. L: questa è l'ultima linea di processo e di riscrivere il processo può essere chiuso. Remember to replace the www.domain.com with your own domain name. Ricordarsi di sostituire il www.domain.com con il tuo nome di dominio.

Brief explaination for second set of rewrite rules and rule conditions Breve explaination per la seconda serie di riscrivere le norme e regola le condizioni

RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L] - This line terminates the trailing slash appending rewrite process if the URL already contains trailing slash. RewriteRule ^ ([a-zA-Z0-9 ]+)/$ / $ 1 [L] - Questa linea termina la barra finale aggiungendo processo di riscrittura se l'URL contiene già barra finale.

RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([a-zA-Z0-9]+) - This line determines request that does not ends with trailing slash. RewriteCond% () THE_REQUEST ^ [AZ] (3,9) \ / ([a-zA-Z0-9] +) - Questa linea determina richiesta che non finisce con la barra finale.

RewriteRule ^([a-zA-Z0-9]+)$ /%1/? RewriteRule ^ ([a-zA-Z0-9] +) $ /% 1 /? [R=301,L] - This line append a slash to the end of URI and perform a 301 permanent redirect to the new URL with trailing slash, and terminate the rewrite block. [R = 301, L] - Questa linea di aggiungere una barra alla fine di URI e 301 eseguire un redirect al nuovo URL con barra finale, e porre fine al blocco di riscrittura.

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Questa è una pagina tradotta macchina che è fornito "così com'è" senza alcuna garanzia. Machine translation may be difficult to understand. Traduzione automatica può essere difficile da capire. Please refer to Si prega di fare riferimento a original English article articolo originale in lingua inglese whenever possible. quando possibile.

Share and contribute or get technical support and help at Condividere e contribuire o ottenere supporto tecnico e assistenza in My Digital Life Forums La mia vita digitale Forum .



One Response to “Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules” Una risposta a "Aggiungi barra alla fine della Fine del URL con. Htaccess Riscrivere Regole"

  1. Na SEO muÅ¡ke - Vybrali.sme.sk a ukonÄ ujúce lomeno v URL | SEO chat Na SEO muÅ ¡ke - Vybrali.sme.sk uno ukonÄ ujà º ce lomeno / URL | SEO chat
    July 26th, 2008 05:19 26 luglio 2008 05:19
    1

    [...] Ä Ãm predÃdete aj problému Ä .2. [...] Ä Ãm predÃdete aj problà © mu Ä .2. Pre htaccess som naÅ¡iel pekný, ale anglický Ä lánok o tom, how to add trailing slash to the end of the URL. Htaccess som pre naÅ ¡IEL peknà ½, ale anglickà ½ Ä là ¡NOK o tom, come aggiungere la barra finale e la fine del URL. Možnosti máte [...] MoÅ ¾ nosti mà ¡te [...]

Leave a Reply Lasciare una risposta

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> È possibile utilizzare questi tag: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime = ""> <em> <i> <q Cite=""> <strike> <strong>

Subscribe without commenting Iscriviti senza commentare


Custom Search

New Articles Nuovi articoli

Incoming Search Terms for the Article Cerca in arrivo Condizioni per l'articolo

mod rewrite trailing slash mod riscrivere barra finale - -- mod rewrite add slash mod riscrivere aggiungere barra - -- mod_rewrite add trailing slash mod_rewrite aggiungere barra finale - -- mod_rewrite append slash mod_rewrite append barra - -- mod_rewrite add slash mod_rewrite aggiungere barra - -- 301 trailing slash 301 barra finale - -- mod rewrite add trailing slash mod riscrivere aggiungere barra finale - -- php htaccess urls slash htaccess PHP barra degli URL - -- trailing slash htaccess barra htaccess - -- trailing slash barra - -- .htaccess add trailing slash . htaccess aggiungere barra finale - -- rewriterule add trailing slash RewriteRule aggiungere barra finale - -- htaccess redirect slash htaccess reindirizzare barra - -- mod_rewrite append trailing slash mod_rewrite append barra finale - -- apache rewrite trailing slash Apache riscrivere barra finale - -- wordpress add slash at end of url wordpress barra aggiungere alla fine del url - -- joomla remove trailing slash Joomla rimuovere barra finale - -- apache rewrite add trailing slash Apache riscrivere aggiungere barra finale - -- how to remove multiple slashes from domain come rimuovere da più barre di dominio - -- rewriterule trailing slash RewriteRule barra finale - -- mod rewrite append trailing slash mod riscrivere append barra finale - -- RewriteRule slash RewriteRule barra - -- directory slash rewrite Directory barra di riscrittura - -- htaccess remove trailing slash htaccess rimuovere barra finale - -- RewriteRule fix trailing slash RewriteRule fissare barra finale - -- apache rewrite add slash Apache riscrivere aggiungere barra - -- mod rewrite optional trailing slash mod riscrivere opzionale barra finale - -- "add slash" htaccess "aggiungere barra" htaccess - -- rewrite url trailing slash riscrittura URL barra finale - -- wordpress trailing slash url WordPress barra URL - -- htaccess redirect trailing slash htaccess reindirizzare barra finale - -- php slash url PHP barra URL - -- htaccess add slash htaccess aggiungere barra - -- htaccess add trailing slash htaccess aggiungere barra finale - -- apache slash at end of url apache barra alla fine del url - -- mod_rewrite slash mod_rewrite barra - -- mod_rewrite remove trailing slash mod_rewrite rimuovere barra finale - -- php + rewrite + add trailing slash php + + aggiungi riscrivere barra finale - -- rewrite add trailing slash riscrivere aggiungere barra finale - -- seo trailing slash Seo barra finale - -- url trailing slash URL barra finale - -- rewrite htaccess add slash htaccess aggiungere riscrivere barra - -- htaccess ending slash htaccess termina barra - -- remove trailing slash htaccess rimuovere barra htaccess - -- rewrite add trailing slash to url riscrivere aggiungere barra alla fine di url - -- rewrite trailing slash riscrivere barra finale - -- mod_rewrite slash at the end mod_rewrite barra alla fine - -- htaccess add trailing slash directory htaccess aggiungere barra directory - -- php remove trailing slash PHP rimuovere barra finale - -- add slash rewrite aggiungere barra di riscrittura - --