Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules Add Trailing Slash ans Ende der URL mit. Htaccess Rewrite-Regeln
For a website that has URLs that end with a slash (/), it's a 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. Für eine Website, die URLs, die mit einem Schrägstrich (/), ist es eine gute Vorgehensweise, um sicherzustellen, dass alle URL-Links von der Web-Server mit einem Schrägstrich beendet analysiert worden, auch wenn die Besucher mit Slash am Ende geben Sie vergessen. 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. Dies zu vermeiden wurden die Besucher mit 404 Page Not Found oder Page serviert kann nicht angezeigt werden Fehler als einige Web-Server Links zu behandeln, ohne Schrägstrich als Datei-Namen statt des Verzeichnisses, und somit nicht in der Lage, die Dokumente zu finden. 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. Es beseitigt auch die Möglichkeit, dass beide Seiten mit gleichem Inhalt, eine mit Schrägstrich am Ende und eine andere, ohne die von Suchmaschinen als Duplikat des Contents angesehen.
As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/. Wie ein Beispiel alle Treffer http://www.mydigitallife.info/contact sollte Umleitung zu 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. Die meisten Web-Server, einschließlich dem populären Apache HTTPD Web Server unterstützt mod_rewrite Modul, in dem Regeln können eingestellt werden. Htaccess-Datei, um die Umleitung zu abschließenden Schrägstrich hinzufügen, um die URLs, die nicht bereits eine besitzen.
The following code can be put in .htaccess to redirect URL without trailing slash to URL with trailing slash: Der folgende Code kann in gesetzt werden. Htaccess zu URL ohne abschließenden Schrägstrich zu URL mit einem Schrägstrich umzuleiten:
RewriteEngine On RewriteEngine On
RewriteBase / RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond% (REQUEST_URI)!-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 oder
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond% (REQUEST_URI)!-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 oder
RewriteEngine On RewriteEngine On
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]+) THE_REQUEST RewriteCond% () ^ [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 der von Ihnen verwendete CMS oder Blog wie Wordpress, die benutzerdefinierte URL-Struktur für Permalinks, vor allem für Suchmaschinen-Optimierung (SEO), den obigen Code sollte vor dem Block der rewrite Regeln und Bedingungen für die URL-Anpassung für das CMS oder Blog-Plattform kommen können .
Brief explaination of the rewrite code to add trailing slash to URL Kurze Erläuterungen des Rewrite-Code hinzufügen abschließenden Schrägstrich zu URL
RewriteEngine On – This line enables the runtime rewriting engine based on mod_rewrite module of Apache. RewriteEngine On - Diese Linie ermöglicht es die Laufzeit-Rewriting-Engine auf mod_rewrite Modul von Apache beruhen.
RewriteBase / – This line sets the current page root directory as base URL for per-directory rewrites. RewriteBase / - Diese Zeile enthält die aktuelle Seite Root-Verzeichnis als Basis-URL für jedes einzelne Verzeichnis schreibt.
RewriteCond %{REQUEST_FILENAME} !-f – This line excludes all URLs pointing to existed files from been added with trailing slash again. RewriteCond% (REQUEST_URI)!-F - Diese Zeile schließt alle URLs auf, um Dateien bestanden aus mit Schrägstrich am Ende wieder aufgenommen. Directories cannot be excluded as this would exclude the rewrite behavior for existing directories. Verzeichnisse können nicht ausschließen, da dies den Rewrite-Verhalten für vorhandene Verzeichnisse ausgeschlossen werden.
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 - Diese Zeile ist optional, und schließt eine Beispiel-URL (in diesem Fall, index.php), dass die Nutzer nicht wollen, dass er neu geschrieben werden. Remove this line if not necessary. Entfernen Sie diese Zeile, wenn nicht notwendig.
RewriteCond %{REQUEST_URI} !\..+$ – Specify that the URL does not contain any . RewriteCond% (REQUEST_URI)! \ .. + $ - Geben Sie die URL nicht enthalten. (dot) to exclude reference to file. (dot) die Bezugnahme auf Datei auszuschließen.
RewriteCond %{REQUEST_URI} !(.*)/$ – This line determines which URL doesn't contain a trailing slash RewriteCond% (REQUEST_URI) !(.*)/$ - Diese Zeile legt fest, welche URL nicht enthält ein Schrägstrich
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] - Diese Zeile Prozess URL ohne abschließenden Schrägstrich bestanden hat, dass Bedingungen, die oben gesetzt, durch Anhängen einer abschließenden Schrägstrich und leiten Sie anschließend mit 301 oder dauerhafte Umleitung Status auf die neue URL. L mean this is the last line to process and the rewrite process can be terminated. L bedeutet dies die letzte Zeile zu verarbeiten und zu den Rewrite-Prozess beendet werden kann. Remember to replace the www.domain.com with your own domain name. Denken Sie daran, die www.domain.com mit Ihrem eigenen Domain-Namen.
Brief explaination for second set of rewrite rules and rule conditions Kurze Erläuterungen für die zweite Satz von Rewrite-Regeln und Bedingungen Regel
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] - Diese Zeile endet der Schrägstrich angehängt umschreiben Prozess, wenn die URL enthält bereits abschließenden Schrägstrich.
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([a-zA-Z0-9]+) – This line determines request that does not ends with trailing slash. THE_REQUEST RewriteCond% () ^ [AZ] (3,9) \ / ([a-zA-Z0-9] +) - Diese Zeile bestimmt Anfrage, die nicht endet mit einem Schrägstrich.
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] - Diese Zeile append einem Schrägstrich an das Ende der URI und führen Sie eine 301 dauerhafte Umleitung auf die neue URL mit einem Schrägstrich, und beendet das umschreiben zu blockieren.
IMPORTANT : The page is machine translated and provided "as is" without warranty. WICHTIG: Die Seite ist Maschine übersetzt und "as is" ohne Garantie. Machine translation may be difficult to understand. Maschinelle Übersetzung kann schwierig zu verstehen. Please refer to Bitte beachten Sie original English article Original Englisch Artikel whenever possible. wann immer möglich.
Related Articles In Verbindung stehende Artikel
- Redirect or Rewrite to Remove Double or Multiple Slashes (//) in URL Redirect oder Rewrite Entfernen von doppelten oder mehrfachen Schrägstriche (/ /) in URL
- SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder SEO Friendly Rewrite Method to Move Website URL From Unterverzeichnis zu Root Parent Folder
- Microsoft Confirmed Price Slash on Xbox Consoles to Stay Competitively in Gaming Segment Microsoft hat bestätigt, Preis Slash auf Xbox Konsolen Reiseplanung Wettbewerbsfähiger in Gaming-Segment
- D-Link Announced Price Slash on Entry Level 802.11n Wireless Router D-Link Announced Preis Slash am Entry Level 802.11n Wireless Router
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Entfernen oder Trim ersten oder letzten paar Zeichen in MySQL Datenbank mit SQL
- WordPress Permalinks Does Not Work in xampp Setup WordPress Permalinks funktioniert nicht in xampp Setup
- PHP Scripts open_basedir Restriction in Effect Error PHP Scripts open_basedir restriction in effect Fehler
- Unable to Logon to Win2003 Domain AD Due to Windows Cannot Connect to the Domain Error Unable to Logon auf Win2003 AD Domain auf Grund des Windows kann nicht auf die Domain Fehler Connect
- Google Domain Names Registration and Search for Free Apps for Your Domain Google Domain Names Registration and Search for Free Apps für Ihre Domain
- Free .BIZ Domain Name Registration for 1 Year from 1&1 Internet (1and1.com) Free. BIZ Domain Name Registration für 1 Jahr von 1 & 1 Internet (1and1.com)










































September 1st, 2009 00:47 1. September 2009 00:47
Thanx. Thanx. Worked perfectly for me. Funktionierte perfekt für mich. Even wordpress uses the same code in .htaccess. Auch wordpress verwendet die gleiche Code in. Htaccess.
August 19th, 2009 07:07 19. August 2009 07:07
Couldn't get the second option to work for me either. Könnte nicht die zweite Option, für mich zu funktionieren. Getting a 500 error. Anreise einen 500-Fehler.
January 19th, 2009 19:50 19. Januar 2009 19:50
I'd been using that slash alot on one of my website. Ich hatte mit, dass viele Schrägstrich auf einer meiner Website. Most of them had been indexed by search engine successfully, but four of them return a 404 not found error based on Google Webmaster report, weird. Die meisten von ihnen waren durch Suchmaschine erfolgreich indiziert, aber vier von ihnen wieder ein 404 nicht gefunden "-Fehler auf der Google Webmaster-Bericht, weird basiert.
December 12th, 2008 12:53 12. Dezember 2008 12:53
I have tried both methods and they do work but not with the other statement that I have. Ich habe beide Methoden und sie funktionieren, aber nicht mit den anderen Aussage, dass ich ausprobiert habe. I was wondering exactly what Killswitch meant when he says “play with it a bit.” I tried rearranging the order and that doesn't seem to help, I'm looking for a quick solution here. Ich frage mich, genau das, was Killswitch meinte, als er ", sagt mit ihm spielen ein bisschen." Ich habe versucht Neuordnung der Ordnung und das scheint nicht zu helfen, ich suche eine schnelle Lösung.
December 6th, 2008 10:37 6. Dezember 2008 10:37
This was extremely helpful, I have been trying for the longest time to figure out how to end a site.com/somthing to site.com/something/ with no luck. Das war sehr hilfreich, habe ich versucht, für die längste Zeit, um herauszufinden, wie man ein Ende site.com / somthing zu site.com / etwas / ohne Glück. Had to play with it a bit due to the rules I already have, but had it working in about 5 mins. Hatte mit ihm zu spielen ein bisschen durch die Regeln, die ich schon hatte, aber es funktioniert in etwa 5 Minuten.
October 31st, 2008 03:07 31. Oktober 2008 03:07
dlvrq rjdkq bfuwo jnlx dlvrq rjdkq bfuwo jnlx
July 26th, 2008 05:19 26. Juli 2008 05:19
[...] Ä Ãm predÃdete aj problému Ä .2. [...] A Am predÃdete aj problà © mu A .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 naa ¡iel pekna ½, ale anglická ½ à là ¡nok o tom, wie man hinzufügen abschließenden Schrägstrich an das Ende der URL. Možnosti máte [...] Moa ¾ nosti mà ¡te [...]