Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules Añadir barra diagonal al final de la URL. Htaccess Reglas de reescritura
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. Para que un sitio web que contiene URL que terminar con una barra (/), es una buena práctica para garantizar que todos los enlaces URL sido analizada por el servidor web terminó con barra diagonal, aun cuando los visitantes se olvide de poner fin a entrar en la 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. Esta evitar los visitantes se sirvieron con 404 Página no encontrada o no se puede mostrar el error, ya que algunos servidores web enlaces sin tratar barra diagonal como un nombre de archivo en lugar de directorio, y, por tanto, incapaz de localizar los documentos. 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. También elimina la posibilidad de que ambas páginas con el mismo contenido, con una barra diagonal al final y sin otro, se considera por los motores de búsqueda como contenido duplicado.
As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/. A modo de ejemplo, todos los éxitos a http://www.mydigitallife.info/contact debe reorientar a 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 mayoría de servidor web, incluido el popular Apache httpd servidor web apoya módulo mod_rewrite, donde las reglas se pueden establecer en. Htaccess archivo a fin de reorientarlos para añadir barra diagonal a la URL que ya no tiene uno.
The following code can be put in .htaccess to redirect URL without trailing slash to URL with trailing slash: El siguiente código se puede poner en. Htaccess para redirigir URL sin barra diagonal al final de la URL con barra diagonal:
RewriteEngine On El Reescribirmotor
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 El Reescribirmotor
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. En que se está usando o blog CMS como Wordpress que permite URL personalizada estructura de permalinks, especialmente para optimización de motores de búsqueda (SEO), el código anterior debe presentarse ante el bloque de reescribir las condiciones y normas para la URL de personalización para el CMS o blog plataforma .
Brief explaination of the rewrite code to add trailing slash to URL Breve explicación de la reescritura de código para añadir barra diagonal a URL
RewriteEngine On - This line enables the runtime rewriting engine based on mod_rewrite module of Apache. El Reescribirmotor - Esta línea permite la reescritura del motor de tiempo de ejecución basado en el módulo mod_rewrite de Apache.
RewriteBase / - This line sets the current page root directory as base URL for per-directory rewrites. RewriteBase / - Esta línea establece la página actual directorio raíz como base para la URL por directorio reescribe.
RewriteCond %{REQUEST_FILENAME} !-f - This line excludes all URLs pointing to existed files from been added with trailing slash again. RewriteCond% (REQUEST_FILENAME)-f - Esta línea excluye a todas las URL que apunta a la existencia de archivos se añadió con barra diagonal de nuevo. Directories cannot be excluded as this would exclude the rewrite behavior for existing directories. Los directorios no se puede excluir, ya que ello excluya la reescritura de comportamiento para los directorios.
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 - Esta línea es opcional, y se excluye a una URL de muestra (en este caso, index.php) que los usuarios no quieren que sea reescrito. Remove this line if not necessary. Quite esta línea si no es necesario.
RewriteCond %{REQUEST_URI} !\..+$ - Specify that the URL does not contain any . RewriteCond% (REQUEST_URI)! \ .. + $ - Especifica que la URL no contiene ninguna. (dot) to exclude reference to file. (punto) para excluir referencia al archivo.
RewriteCond %{REQUEST_URI} !(.*)/$ - This line determines which URL doesn’t contain a trailing slash RewriteCond% (REQUEST_URI) !(.*)/$ - Esta línea determina que la URL no contiene una barra diagonal
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] - Esta línea URL proceso sin barra diagonal que ha transcurrido condiciones establecidas anteriormente, añadiendo una barra diagonal y, a continuación, con redirección 301 o permanente redirigir a la nueva URL. L mean this is the last line to process and the rewrite process can be terminated. L significa que esta es la última línea de proceso y el proceso de reescritura puede darse por concluido. Remember to replace the www.domain.com with your own domain name. Recuerde reemplazar el www.domain.com con su propio nombre de dominio.
Brief explaination for second set of rewrite rules and rule conditions Breve explicación para la segunda serie de reescribir las reglas y condiciones regla
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] - Esta línea termina la barra diagonal añadiendo proceso de reescritura de si la URL ya contiene barra diagonal.
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] +) - Esta línea determina que la solicitud no termina con barra diagonal.
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] - Esta línea añadirá una barra diagonal al final del URI y realizar una redirección permanente 301 a la nueva URL con barra diagonal, y poner fin a la reescritura de bloque.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Se trata de una máquina que traduzca la página se proporciona "tal cual" sin garantía. Machine translation may be difficult to understand. La traducción automática puede resultar difícil de entender. Please refer to Por favor, consulte original English article artículo original Inglés whenever possible. siempre que sea posible.
Share and contribute or get technical support and help at Compartir y contribuir o recibir apoyo técnico y ayudar a My Digital Life Forums Mi vida digital Foros .
Related Articles Artículos relacionados
- Redirect or Rewrite to Remove Double or Multiple Slashes (//) in URL Reorientar o reescritura para Eliminar dobles o múltiples barras inclinadas (/ /) en la URL
- SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder SEO Friendly reescribir método para mover la URL del sitio web de subdirectorio a raíz carpeta
- Remove and Uninstall or Disable ModSecurity (mod_security) Retire y Desinstalar o Desactivar ModSecurity (mod_security)
- WordPress Permalinks Does Not Work in xampp Setup WordPress permalinks no funciona en configuración de XAMPP
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Eliminar o Trim primera o la última caracteres en la base de datos MySQL con SQL
- How to Move WordPress Blog to New Domain or Location Cómo pasar a WordPress blog nuevo dominio o ubicación
- Fix Session Save Path Red Unwritable When Installing Joomla! Fix período de sesiones guardar camino rojo Unwritable Al instalar Joomla!
- How to Add a MySpace User As Friend in Friends List Cómo agregar un usuario de MySpace como amigo en la lista de amigos
- How to Activate and Use FeedBurner MyBrand for Free Cómo activar y usar FeedBurner MyBrand Gratis
- How to Add and Put Picture or Image in MySpace Comment Cómo agregar y poner la imagen fotográfica o en MySpace Comentario













July 26th, 2008 05:19 26 de Julio, 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. Pre htaccess som naÅ ¡iel peknà ½, ale anglickà ½ Ä là ¡Nok o tom, cómo añadir barra diagonal al final de la URL. Možnosti máte [...] MoÅ ¾ nosti mà ¡te [...]