Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules הוסף נגררים Slash כדי בסוף כתובת עם. כללים השכתוב htaccess

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. עבור אתר אינטרנט יש כתובות המסתיימות נטוי (/), זה אימון טוב על מנת להבטיח כי כל הקישורים url כבר מנותח על ידי שרת האינטרנט הסתיימה עם קו נטוי נגרר, גם אם המבקרים לשכוח להיכנס לוכסן הסוף. 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. זה להימנע מבקרים הוגשה עם 404 דף לא נמצא או לא יכול להיות דף שגיאה הוצג כמו בשרתי אינטרנט לטפל קישורים ללא קו נטוי נגרר כשם קובץ בספרייה במקום, וכך הצליחה לאתר את המסמכים. 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. זה גם מבטל את האפשרות כי שני דפים עם תוכן זהה, אחד עם קו נטוי בסוף ועוד בלי, נתפסו על ידי מנועי חיפוש כפי תוכן כפולים.

As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/. כדוגמה, כל hits כדי http://www.mydigitallife.info/contact יש להפנות 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. רוב שרת אינטרנט, כולל שרת האינטרנט הפופולרי Apache httpd תומך mod_rewrite מודול שבו כללי ניתן להגדיר. קובץ htaccess כדי לנתב להוסיף קו נטוי נגרר אל כתובות זה לא כבר אחד.

The following code can be put in .htaccess to redirect URL without trailing slash to URL with trailing slash: את הקוד הבא ניתן לשים. Htaccess כדי לנתב מחדש את כתובת האתר ללא קו נטוי נגרר אל כתובת נגרר עם קו נטוי:

RewriteEngine On RewriteEngine On
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 או

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 או

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]+) 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. אתה משתמש ב-CMS או הבלוג כגון Wordpress המאפשר מבנה URL מותאם אישית עבור permalinks, במיוחד עבור אופטימיזציה למנועי חיפוש (SEO), את הקוד לעיל צריך לבוא לפני לחסום את השכתוב של תנאים וכללים עבור התאמה אישית של כתובת האתר או הבלוג פלטפורמת CMS .

Brief explaination of the rewrite code to add trailing slash to URL Explaination קצרה של לשכתב קוד כדי להוסיף קו נטוי נגרר אל כתובת

RewriteEngine On – This line enables the runtime rewriting engine based on mod_rewrite module of Apache. RewriteEngine ב - קו זה מאפשר Runtime שכתוב מנוע המבוסס על המודול mod_rewrite של אפאצ 'י.

RewriteBase / – This line sets the current page root directory as base URL for per-directory rewrites. RewriteBase / - שורה זו מגדירה את המדריך הנוכחי השורש דף ככתובת הבסיס לכל משכתב המדריך.

RewriteCond %{REQUEST_FILENAME} !-f – This line excludes all URLs pointing to existed files from been added with trailing slash again. RewriteCond% (REQUEST_FILENAME)!-F - שורה זו אינה כוללת את כל כתובות האתרים והצביע על קבצים התקיימה בין נוספו עם קו נטוי נגרר שוב. Directories cannot be excluded as this would exclude the rewrite behavior for existing directories. מדריכים לא יכול להיות שליליים כמו זה יהיה להוציא את לשכתב התנהגות עבור ספריות הקיימות.

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 - קו זה הוא אופציונלי, ויהיה כולל כתובת אתר לדוגמה (במקרה זה, index.php) כי משתמשים לא רוצה שזה יהיה מחדש. Remove this line if not necessary. הסר את הקו הזה אם לא הכרחי.

RewriteCond %{REQUEST_URI} !\..+$ – Specify that the URL does not contain any . RewriteCond% (REQUEST_URI)! \ .. + $ - לציין את כתובת האתר אינו מכיל. (dot) to exclude reference to file. (נקודה) כדי לכלול הפניה לקובץ.

RewriteCond %{REQUEST_URI} !(.*)/$ – This line determines which URL doesn't contain a trailing slash RewriteCond% (REQUEST_URI) !(.*)/$ - שורה זו קובעת את כתובת האתר אינו מכיל קו נטוי נגרר

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] - זו כתובת תהליך קו נטוי נגרר ללא תנאים שחלף מעל הגדר, על ידי צירוף קו נטוי נגרר ולאחר מכן כוון מחדש עם 301 או מעמד קבע מחדש לכתובת החדשה. L mean this is the last line to process and the rewrite process can be terminated. כלומר זו היא השורה האחרונה על מנת לעבד את התהליך מחדש יכולה להיפסק. Remember to replace the www.domain.com with your own domain name. זכור להחליף את www.domain.com עם בשם התחום שלך.

Brief explaination for second set of rewrite rules and rule conditions Explaination בקצרה על הסדרה השנייה של לשכתב כללים ותנאים שלטון

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] - זה קו נטוי נגרר מסיים את תהליך צירוף לשכתב את כתובת האתר אם כבר מכיל קו נטוי נגרר.

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] +) - שורה זו קובעת כי הבקשה אינה מסתיימת עם קו נטוי נגרר.

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] - שורה זו כדי להוסיף קו נטוי בסוף אורי לבצע הפניה 301 קבע לכתובת חדשה עם קו נטוי נגרר, וכן לסיים את השכתוב לחסום.

IMPORTANT : The page is machine translated and provided "as is" without warranty. חשוב: הדף מכונת תירגם מתפרסם "כמות שהוא" ללא אחריות. Machine translation may be difficult to understand. תרגום מכונה יכול להיות קשה להבין. Please refer to נא עיין original English article המאמר המקורי באנגלית whenever possible. בכל הזדמנות אפשרית.


7 Responses to “Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules” 7 תגובות ל "הוסף נגררים Slash כדי בסוף כתובת עם. כללים השכתוב htaccess"

  1. Sushant Sushant
    September 1st, 2009 00:47 1 ספטמבר 2009 00:47
    7 7

    Thanx. Thanx. Worked perfectly for me. עבד בצורה מושלמת בשבילי. Even wordpress uses the same code in .htaccess. גם וורדפרס משתמשת באותו קוד ב. Htaccess.

  2. any dog breed כל גזע הכלב
    August 19th, 2009 07:07 19 אוגוסט 2009 07:07
    6 6

    Couldn't get the second option to work for me either. אין אפשרות לקבל את האפשרות השנייה לעבוד גם לי. Getting a 500 error. מקבל שגיאה 500.

  3. an office equipment seller מוכרת ציוד משרדי
    January 19th, 2009 19:50 19 ינואר 2009 19:50
    5 5

    I'd been using that slash alot on one of my 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. רובם היו לאינדקס של מנוע החיפוש בהצלחה, אבל ארבעה מהם להחזיר שגיאה 404 לא נמצא על בסיס הדו"ח-Google Webmaster, מוזר.

  4. Nate נאט
    December 12th, 2008 12:53 12 דצמבר 2008 12:53
    4 4

    I have tried both methods and they do work but not with the other statement that I have. ניסיתי את שתי השיטות והם עושים את העבודה אבל לא עם הקביעה אחרים שיש לי. 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. תהיתי מה בדיוק Killswitch מתכוון כשהוא אומר "לשחק עם זה קצת." ניסיתי לסדר מחדש את הסדר וזה לא נראה לעזור, אני מחפש פתרון מהיר כאן.

  5. Killswitch Killswitch
    December 6th, 2008 10:37 6 דצמבר 2008 10:37
    3 3

    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. זה היה מאוד מועיל, אני מנסה המון זמן להבין איך לסיים site.com / somthing כדי site.com / משהו / ללא הצלחה. Had to play with it a bit due to the rules I already have, but had it working in about 5 mins. צריך לשחק עם זה קצת בשל הכללים כבר יש לי, אבל זה היה עובד בערך 5 דקות.

  6. com com
    October 31st, 2008 03:07 31 אוקטובר 2008 03:07
    2 2

    dlvrq rjdkq bfuwo jnlx dlvrq rjdkq bfuwo jnlx

  7. Na SEO muÅ¡ke - Vybrali.sme.sk a ukonÄ ujúce lomeno v URL | SEO chat Na-SEO אל muÅ ¡- Vybrali.sme.sk ukonÄ UJA º לסה"נ lomeno V כתובת | SEO צ 'אט
    July 26th, 2008 05:19 26 יולי 2008 05:19
    1 1

    [...] Ä Ãm predÃdete aj problému Ä .2. [...] יי am predÃdete AJ problà © יי מו .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 naa ¡iel peknà וחצי, אייל anglickà ½ à la ¡NOK O טום, כיצד להוסיף קו נטוי נגרר לסוף את כתובת האתר. Možnosti máte [...] מואה ¾ nosti ma ¡te [...]

Leave a Reply השאירו תגובה

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> באפשרותך להשתמש בתגים אלה: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime = ""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. כדי להירשם הערות תכונה הושבת. To receive notification of latest comments posted, subscribe to כדי לקבל הודעה העדכנית של תגובות, כדי להירשם My Digital Life Comments RSS feed שלי חיים דיגיטלי תגובות RSS Feed or או register to receive הרשמה לקבלת new comments in daily email digest. תגובות חדש ב דוא"ל תקציר יומי.
Custom Search

New Articles מאמרים חדשים

Incoming Search Terms for the Article תנאי נכנסות חיפוש עבור מאמרים

google maps trailing slash מפות Google נגרר נטוי - -- htaccess append # to every url htaccess # כדי לצרף את כתובת האתר בכל - -- htaccess redirect "trailing slash" redirect htaccess "קו נטוי נגרר" - -- htaccess same domain redirect multiple condition htaccess תחום אותו מחדש במצב מרובים - -- joomla add slash in url Joomla להוסיף לוכסן ב-URL - -- mod rewrite slash mod rewrite לוכסן - -- rewriterule trailing slash RewriteRule נגרר נטוי - -- rewriterule add ending slash RewriteRule לסיום להוסיף לוכסן - -- rewrite htaccess add trailing slash לשכתב htaccess להוסיף קו נטוי נגרר - -- wordpress in subdirectory has trailing slash WordPress בתיקיית יש נגרר נטוי - -- wordpress add trailing slash WordPress להוסיף קו נטוי נגרר - -- apache trailing slash rewrite אפאצ 'י קו נטוי נגרר לשכתב - -- htaccess rewrite, replace slash htaccess rewrite, להחליף קו נטוי - -- mod_rewrite add slash mod_rewrite להוסיף לוכסן - -- nginx add slash uri Nginx להוסיף לוכסן אורי - -- redirect is adding slash to end of url הפניה היא הוספת קו נטוי עד הסוף של כתובת האתר - -- url rewrite to remove ending slash כתובת לשכתב להסיר סיום לוכסן - -- end slash קו נטוי סוף - -- .htaccess get trailing slash . htaccess להשיג נגרר נטוי - -- Add trailing slash to all URl הוסף קו נטוי נגרר לכל URL - -- apache rewrite ending slash Apache לשכתב את הסוף לוכסן - -- append slash to href כדי להוסיף קו נטוי href - -- attaching an ending slash in path הוספת קו נטוי סוף בנתיב - -- auto add / slash to url Auto add / לוכסן לכתובת - -- how to add slashes at end with .htaccess כיצד להוסיף בסוף עם חתכים. htaccess - -- htaccess trailing slash htaccess נגרר נטוי - -- htaccess rewrite trailing slash htaccess rewrite נגרר נטוי - -- htaccess slash לוכסן htaccess - -- htaccess redirect to slash redirect htaccess לחתוך - -- RewriteRule slash RewriteRule לוכסן - -- url trailing slash required כתובת נגרר נטוי חובה - -- url rewriter.net slash trailing remove rewriter.net url קו נטוי נגרר להסיר - -- using trailing slash for base url באמצעות קו נטוי נגרר על בסיס כתובת - --