.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.
Related Articles
- Redirect or Rewrite to Remove Double or Multiple Slashes (//) in URL
- SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder
- Remove and Uninstall or Disable ModSecurity (mod_security)
- WordPress Permalinks Does Not Work in xampp Setup
- Remove or Trim First or Last Few Characters in MySQL Database with SQL
- How to Move WordPress Blog to New Domain or Location
- Fix Session Save Path Red Unwritable When Installing Joomla!
- How to Add a MySpace User As Friend in Friends List
- How to Activate and Use FeedBurner MyBrand for Free
- How to Add and Put Picture or Image in MySpace Comment




























July 26th, 2008 05:19
[...] Äá©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 [...]