Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules Adicionar barra final para o final da URL com. Htaccess Regras de regravação

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 um site que tem URLs que terminam com uma barra (/), é uma boa prática para garantir que todas as ligações url sido analisado pelo servidor terminou com barra final, mesmo que os visitantes se esqueça de inserir o termo 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. Este evitar visitantes foram servidos com 404 Página não encontrada ou página não pode ser exibida erro, uma vez que alguns servidores web tratar de ligações sem barra final como um nome de arquivo em vez do diretório, e, portanto, incapaz de localizar os 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. Ele também elimina a possibilidade de que as duas páginas com o mesmo conteúdo, com uma barra no final e outra sem, foram vistas pelos motores de busca como conteúdo duplicado.

As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/. Como um exemplo, todos os acessos a http://www.mydigitallife.info/contact deve ser redirecionar 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. A maior parte do servidor da web, incluindo o popular servidor web Apache HTTPD apoia o mod_rewrite módulo onde podem ser definidos na regulamentação. Htaccess arquivo a fim de redirecionar para adicionar à barra final URLs que ainda não tem uma.

The following code can be put in .htaccess to redirect URL without trailing slash to URL with trailing slash: O código a seguir pode ser posta em. Htaccess para redirecionar URL sem barra de URL com barra:

RewriteEngine On Regravar mecanismo em
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 ou

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

or ou

RewriteEngine On Regravar mecanismo em
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. Em que você está usando CMS ou blog como o Wordpress que permite URL personalizado estrutura de permalinks, especialmente para a otimização motor de busca (SEO), o referido código deve vir antes de o bloco de condições e regras para reescrever URL personalização para a plataforma CMS ou blog .

Brief explaination of the rewrite code to add trailing slash to URL Breve explaination de reescrever o código de barra para adicionar URL

RewriteEngine On - This line enables the runtime rewriting engine based on mod_rewrite module of Apache. Regravar mecanismo em - Esta linha permite que o motor de runtime reescrevendo o mod_rewrite baseada no módulo do Apache.

RewriteBase / - This line sets the current page root directory as base URL for per-directory rewrites. RewriteBase / - Esta linha define a página atual diretório raiz como base para a URL reescrito por-diretório.

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 linha exclui todos os URLs que apontam para existiu a partir de arquivos foram adicionados com a barra de novo. Directories cannot be excluded as this would exclude the rewrite behavior for existing directories. Diretórios não pode ser excluída, pois tal comportamento para reescrever a excluir diretórios existentes.

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 linha é opcional, e irá exclui uma amostra URL (neste caso, index.php) que os usuários não querem que ele seja reescrito. Remove this line if not necessary. Remova esta linha se não for necessário.

RewriteCond %{REQUEST_URI} !\..+$ - Specify that the URL does not contain any . RewriteCond% (REQUEST_URI)! \ .. + $ - Especifique o URL que não contém qualquer. (dot) to exclude reference to file. (ponto) excluir a referência ao arquivo.

RewriteCond %{REQUEST_URI} !(.*)/$ - This line determines which URL doesn’t contain a trailing slash RewriteCond% (REQUEST_URI) !(.*)/$ - Esta linha determina URL que não contém uma barra final

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] - Este processo linha URL barra final sem que tenha passado condições estabelecidas acima, por anexando uma barra e, depois, com redirecionamento 301 ou redirecionamento permanente estado para o novo URL. L mean this is the last line to process and the rewrite process can be terminated. L significar esta é a última linha para processar e reescrever o processo pode ser encerrado. Remember to replace the www.domain.com with your own domain name. Lembre-se de substituir o www.domain.com com seu próprio nome de domínio.

Brief explaination for second set of rewrite rules and rule conditions Breve explaination para a segunda série de reescrever as regras e condições regra

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] - Este acordo põe termo a barra anexando processo se reescrever a URL já contém barra.

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 linha determina que o pedido não termina com a barra.

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 linha anexar uma barra para o fim da URI 301 e executar um redirecionamento permanente para a nova URL com barra final, e encerrar o bloco reescrever.

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Esta é uma página traduzida máquina que é fornecida "como está" sem garantia. Machine translation may be difficult to understand. A tradução automática pode ser difícil de compreender. Please refer to Por favor, consulte a original English article Inglês original article whenever possible. sempre que possível.

Share and contribute or get technical support and help at Compartilhe e contribuir ou obter suporte técnico e ajudar a My Digital Life Forums Minha vida digital Fóruns .



One Response to “Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules” Uma resposta a "Adicionar barra final para o final da URL com. Htaccess Regras de regravação"

  1. Na SEO muÅ¡ke - Vybrali.sme.sk a ukonÄ ujúce lomeno v URL | SEO chat Na SEO muÅ ¡ke - Vybrali.sme.sk um ukonÄ ujà º ce lomeno v URL | SEO bate-papo
    July 26th, 2008 05:19 26 de julho de 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. Pré htaccess som naÅ ¡IEL peknà ½, ale anglickà ½ Ä là ¡NOK o tom, como adicionar a barra ao final do URL. Možnosti máte [...] MoÅ ¾ nosti mà ¡te [...]

Leave a Reply Deixe uma resposta

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> Você pode usar estas tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime = ""> <em> <i> <q Cite=""> <strike> <strong>

Subscribe without commenting Subscreva sem comentar


Custom Search

New Articles Novos Artigos

Incoming Search Terms for the Article Incoming Termos de pesquisa para o artigo

mod rewrite trailing slash mod reescrever barra final - -- mod rewrite add slash mod reescrever adicionar uma barra - -- mod_rewrite add trailing slash acrescentar o mod_rewrite barra final - -- mod_rewrite append slash o mod_rewrite append slash - -- mod_rewrite add slash acrescentar o mod_rewrite slash - -- 301 trailing slash 301 barra final - -- mod rewrite add trailing slash mod reescrever acrescentar barra final - -- php htaccess urls slash PHP htaccess URLs slash - -- trailing slash htaccess htaccess barra final - -- trailing slash barra final - -- .htaccess add trailing slash . htaccess acrescentar barra final - -- rewriterule add trailing slash rewriterule acrescentar barra final - -- htaccess redirect slash htaccess redirecionamento slash - -- mod_rewrite append trailing slash o mod_rewrite append barra final - -- apache rewrite trailing slash Apache reescrever barra final - -- wordpress add slash at end of url wordpress adicionar uma barra no fim da url - -- apache rewrite add trailing slash Apache reescrever acrescentar barra final - -- how to remove multiple slashes from domain como remover várias barras de domínio - -- rewriterule trailing slash rewriterule barra final - -- mod rewrite append trailing slash mod reescrever append barra final - -- RewriteRule slash RewriteRule slash - -- directory slash rewrite diretório barra reescrever - -- htaccess remove trailing slash htaccess remover barra final - -- RewriteRule fix trailing slash RewriteRule fixar barra final - -- apache rewrite add slash Apache reescrever adicionar uma barra - -- mod rewrite optional trailing slash mod reescrever opcional barra final - -- "add slash" htaccess "adicionar barra" htaccess - -- rewrite url trailing slash reescrever URL barra final - -- wordpress trailing slash url WordPress barra URL - -- htaccess redirect trailing slash htaccess redirecionamento barra final - -- php slash url PHP barra URL - -- htaccess add trailing slash htaccess acrescentar barra final - -- apache slash at end of url apache barra no fim da url - -- mod_rewrite slash o mod_rewrite slash - -- mod_rewrite remove trailing slash o mod_rewrite remover barra final - -- php + rewrite + add trailing slash php reescrever + + adicionar barra final - -- rewrite add trailing slash reescrever acrescentar barra final - -- seo trailing slash Seo barra final - -- url trailing slash URL barra final - -- rewrite htaccess add slash htaccess reescrever adicionar uma barra - -- htaccess ending slash htaccess terminando slash - -- remove trailing slash htaccess remover barra htaccess - -- rewrite add trailing slash to url reescrever adicionar a barra final url - -- rewrite trailing slash reescrever barra final - -- mod_rewrite slash at the end o mod_rewrite barra no final - -- htaccess add trailing slash directory htaccess acrescentar barra diretório - -- php remove trailing slash PHP remover barra final - -- add slash rewrite adicionar uma barra reescrever - -- apache add slash Apache adicionar uma barra - -- apache redirect trailing slash Apache redirecionar barra final - --