.htaccess °íÃÄ ¾¸ ±ÔÄ¢À» °¡Áø URLÀÇ ³¡¿¡ ²ô´Â ³»¸®Ä§À» Ãß°¡ÇϽʽÿÀ

¸¦ À§ÇÑ À¥»çÀÌÆ® ºñ·Ï ¹æ¹®ÀÚ°¡ °á¸» ³»¸®Ä§¿¡ µé¾î°¡´õ¶óµµ °ÍÀ» ÀØ´õ¶óµµ ³»¸®Ä§¿¡´Â ·Î ³¡³»´Â URL (/), ¸ðµç URL ¿¬°áÀº ²ô´Â ³»¸®Ä§ ·Î À¥ ¼­¹ö ¿¡ ÀÇÇØ ºÐ¼®µÇ¾î ³¡³Â´Ù´Â °ÍÀ» º¸ÁõÇÏ´Â ÁÁÀº ¿¬½À ÀÖ´ÂÀÎ. À̰ÍÀº ¹æ¹®ÀÚ¸¦ ã¾Æ³»Áö ¾Ê´Â ÆäÀÌÁö·Î 404 ºÀ»çµÇ¾î ÇÇÇÑ´Ù ¶Ç´Â ¸î¸î À¥ ¼­¹ö°¡ ÀüÈ­¹øÈ£ºÎ ´ë½Å¿¡ ÆÄÀÏ À̸§À¸·Î ²ô´Â ³»¸®Ä§ ¾øÀÌ ¿¬°áÀ» ´ë¿ìÇÏ´Â ¶§ ÆäÀÌÁö´Â, ÀÌ·¸°Ô ¹®¼­¸¦ ã¾Æ³¾ ¼ö ¾ø½À´Ï´Ù Ç¥½ÃµÈ °ú½ÇÀ̰ñ. ±×°ÍÀº ¶ÇÇÑ ³¡¿¡ °¡´É¼ºÀ» µ¿ÀÏÇÑ ³»¿ëÀ» °¡Áø µÎ ÆäÀÌÁö ´Ù, ³»¸®Ä§¿¡ °Í ¹× ¶Ç ´Ù¸¥ ÇѰ³ ¹Ù±ùÂÊÀ¸·Î, ÀÌÁß ³»¿ëÀ¸·Î ¼ö»ö ¿£Áø¿¡ ÀÇÇØ Àü¸ÁµÇ¾î »èÁ¦ÇÑ´Ù.

ÇÑ ¿¹·Î, http://www.mydigitallife.info/contact¿¡ ¸ðµç ¸íÁßÀº http://www.mydigitallife.info/contact/¿¡ ¹æÇâÀ» ¹Ù²Û´Ù À̾î¾ß ÇÑ´Ù.

´ëÁßÀûÀÎ ¾ÆÆÄÄ¡ HTTPD À¥ ¼­¹ö¸¦ Æ÷ÇÔÇÏ¿© ÃÖ´ë À¥ ¼­¹ö´Â, ÀÌ¹Ì 1°³°¡ ¾ø´Â URL¿¡ ²ô´Â ³»¸®Ä§¿¡´Â Ãß°¡Çϱâ À§ÇÏ¿© ±ÔÄ¢ÀÌ .htaccess ÆÄÀÏ¿¡¼­ ¹æÇâÀ» ¹Ù²Ù±â À§ÇÏ¿© ³õÀÏ ¼ö ÀÖ´Â mod_rewrite ´ÜÀ§¸¦ Áö¿øÇÑ´Ù.

µÚ¿¡ ¿À´Â ºÎÈ£´Â .htaccess¿¡¼­ ²ô´Â ³»¸®Ä§À» °¡Áø URL¿¡ ²ô´Â ³»¸®Ä§ ¾øÀÌ URLÀÇ ¹æÇâÀ» ¹Ù²Ù±â À§ÇÏ¿© ÀÖÀ» ¼ö ÀÖ´Ù:

À§¿¡ RewriteEngine
RewriteBase/
RewriteCond % {REQUEST_FILENAME}! - f
RewriteCond % {REQUEST_URI}! index.php
RewriteCond % {REQUEST_URI}! (. *)/$
RewriteRule ^ (. *) $ http://domain.com/$1/ [L, R=301]

¶Ç´Â

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

¶Ç´Â

À§¿¡ RewriteEngine
RewriteBase/
RewriteRule ^ ([a-zA-Z0-9] +)/$/$1 [L]
RewriteCond % {THE_REQUEST} ^ [A-Z] {\ 3,9ÀÇ}/([a-zA-Z0-9] +)
RewriteRule ^ ([a-zA-Z0-9] +) $/%1/? [R=301, L]

´ç½Å¿¡¼­ CMS¸¦ »ç¿ëÇϰí ÀÖ´Ù ¶Ç´Â °Ë»ö ¿£Áø ÃÖÀûÈ­ (SEO)¸¦ À§ÇÑ permalinks¸¦ À§ÇÑ ÁÖ¹® URL ±¸Á¶¸¦ ƯÈ÷, À§ ºÎÈ£ Çã¿ëÇÏ´Â Wordpress¿Í °°Àº blog´Â CMS blog Ç÷¡Æ®È¨À» À§ÇÑ URL ÁÖ¹®È­¸¦ À§ÇÑ °íÃÄ ¾¸ Á¶°Ç ±×¸®°í ±ÔÄ¢ÀÇ ±¸È¹ÀÇ ¾Õ¿¡ ¿Í¾ß ÇÑ´Ù.

URL¿¡ ²ô´Â ³»¸®Ä§À» Ãß°¡ÇÏ´Â °íÃÄ ¾¸ ºÎÈ£ÀÇ ÂªÀº explaination

À§¿¡ RewriteEngine - ÀÌ ¼±Àº ¾ÆÆÄÄ¡ÀÇ mod_rewrite ´ÜÀ§¿¡ ±Ù°ÅÇÑ ·±Å¸ÀÓ ´Ù½Ã ¾²´Â ¿£ÁøÀ» °¡´ÉÇÏ°Ô ÇÑ´Ù.

RewriteBase/- ÀÌ ¼±Àº ´ç ÀüÈ­¹øÈ£ºÎ °íÃÄ ¾¸À» À§ÇÑ ±âÃÊ URL·Î ÇöÀç ÆäÀÌÁö ·çÆ® µð·ºÅ丮¸¦ ³õ´Â´Ù.

RewriteCond % {REQUEST_FILENAME}! - f - ÀÌ ¼±Àº ²ô´Â ³»¸®Ä§À¸·Î ´Ù½Ã Ãß°¡µÇ´Â¿¡¼­ Á¸ÀçÇÑ ÆÄÀÏÀ» °¡¸£Å°´Â ¸ðµç URL¸¦ Á¦ÇÑ´Ù. ÀüÈ­¹øÈ£ºÎ´Â À̰ÍÀÌ ±âÁ¸ÇÏ´Â ÀüÈ­¹øÈ£ºÎ¸¦ À§ÇÑ °íÃÄ ¾¸ ÇൿÀ» Á¦Çϱ⠶§¹®¿¡ Á¦ÇÒ ¼ö ¾ø´Ù.

RewriteCond % {REQUEST_URI}! index.php - ÀÌ ¼±Àº ¼±Åà À̰í, ÀÇÁö´Â Àú °ßº» URL¸¦ (ÀÌ °æ¿ì¿¡´Â, index.php) »ç¿ëÀÚ ´Ù½Ã ¾²ÀÌ´Â ¿øÇÏÁö ¾Ê´Â´Ù ±×°ÍÀ» Á¦ÇÑ´Ù. ÇÊ¿äÇÑ ÀÌ ¼±À» ±×·¸Áö ¾ÊÀ¸¸é Á¦°ÅÇϽʽÿÀ.

RewriteCond % {REQUEST_URI}! \. +$ - URL°¡ ¹«¾ùÀ̵çÀ» Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù´Â °ÍÀ» ÁöÁ¤ÇϽʽÿÀ. (Á¡) ÆÄÀÏ¿¡ Âü°í¸¦ Á¦Çϱâ À§ÇÏ¿©.

RewriteCond % {REQUEST_URI}! (. *)/$ - ¾î´À URL°¡ ²ô´Â ³»¸®Ä§À» Æ÷ÇÔÇÏÁö ¾Ê´ÂÁö ÀÌ ¼±Àº °áÁ¤ÇÑ´Ù

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. 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.

Brief explaination for second set of rewrite rules and rule conditions

RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L] - This line terminates the trailing slash appending rewrite process if the URL already contains trailing slash.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([a-zA-Z0-9]+) - This line determines request that does not ends with trailing slash.

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.

IMPORTANT: This is a machine translated page which is provided "as is" without warranty. Machine translation may be difficult to understand. Please refer to original English article whenever possible.

Share and contribute or get technical support and help at My Digital Life Forums.



One Response to ¡°Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules¡±

  1. Na SEO muÅ¢®ke - Vybrali.sme.sk a ukončujè¬ce lomeno v URL | SEO chat
    July 26th, 2008 05:19
    1

    [...] čá©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. MoŨúnosti mâ®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>

Subscribe without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

mod rewrite trailing slash - mod rewrite add slash - mod_rewrite add trailing slash - mod_rewrite append slash - mod_rewrite add slash - trailing slash - 301 trailing slash - mod rewrite add trailing slash - apache rewrite add trailing slash - php htaccess urls slash - trailing slash htaccess - .htaccess add trailing slash - rewriterule add trailing slash - htaccess redirect slash - mod_rewrite append trailing slash - apache rewrite trailing slash - wordpress add slash at end of url - joomla remove trailing slash - mod_rewrite remove trailing slash - how to remove multiple slashes from domain - rewriterule trailing slash - mod rewrite append trailing slash - url trailing slash - RewriteRule slash - directory slash rewrite - htaccess remove trailing slash - RewriteRule fix trailing slash - apache rewrite add slash - mod rewrite optional trailing slash - "add slash" htaccess - rewrite url trailing slash - wordpress trailing slash url - htaccess redirect trailing slash - php slash url - htaccess add slash - htaccess add trailing slash - apache slash at end of url - htaccess add slash to end - mod_rewrite slash - wordpress trailing slash - php + rewrite + add trailing slash - rewrite add trailing slash - seo trailing slash - rewrite htaccess add slash - htaccess ending slash - remove trailing slash htaccess - rewrite add trailing slash to url - rewrite trailing slash - mod_rewrite slash at the end - htaccess add trailing slash directory -