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 .
Related Articles Articoli correlati
- Redirect or Rewrite to Remove Double or Multiple Slashes (//) in URL Riscrivere il reindirizzamento o rimuovere doppi o multipli barre (/ /) in URL
- SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder SEO friendly riscrivere metodo per spostare l'URL del sito Web da sottodirectory a root cartella
- Remove and Uninstall or Disable ModSecurity (mod_security) Disinstallare e rimuovere o disattivare ModSecurity (mod_security)
- WordPress Permalinks Does Not Work in xampp Setup WordPress permalink non funziona nel programma di installazione di XAMPP
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Rimuovere o Trim prima o l'ultima pochi caratteri in MySQL Database con SQL
- How to Move WordPress Blog to New Domain or Location Come muoversi a wordpress blog nuovo dominio o la località
- Fix Session Save Path Red Unwritable When Installing Joomla! Fissare sessione Salva percorso rosso Unwritable Durante l'installazione di Joomla!
- How to Add a MySpace User As Friend in Friends List Come aggiungere un utente come MySpace amico in Lista Amici
- How to Activate and Use FeedBurner MyBrand for Free Come attivare e utilizzare FeedBurner MyBrand per Free
- How to Add and Put Picture or Image in MySpace Comment Come aggiungere e mettere immagini o l'immagine in MySpace commento



















July 26th, 2008 05:19 26 luglio 2008 05:19
[...] Ä Ã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 [...]