2015-12-15 40 views
1

我正在使用Wordpress在博客上工作,我無法弄清楚它創建的.htaccess文件正在做什麼。需要幫助瞭解.htaccess文件的內容

下面是該文件的內容:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /welg/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /welg/index.php [L] 
</IfModule> 
# END WordPress 

有誰誰明白這有時間每行解釋一下嗎?任何幫助將不勝感激。

回答

2
# If the mod_rewrite.c module is available then do the following 
<IfModule mod_rewrite.c> 

    # Enable the rewrite engine, which is used to rewrite the 
    # path to something WordPress understands 
    RewriteEngine On 

    # Set the base to this path. In other words, assume that the 
    # website is always at domain.com/welg/ 
    RewriteBase /welg/ 

    # If index.php is called then stop rewriting ([L] means Last) 
    RewriteRule ^index\.php$ - [L] 

    # If the path is NOT a valid file 
    RewriteCond %{REQUEST_FILENAME} !-f 

    # ... and the path is NOT a valid folder 
    RewriteCond %{REQUEST_FILENAME} !-d 

    # ... then always load the index.php file (which will handle 
    # loading the page, no matter what the path is) 
    RewriteRule . /welg/index.php [L] 

# Done 
</IfModule> 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.php$ /welg/index.php [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /welg/index.php [L] 
</IfModule> 
+0

如果我有welg目錄WP的所有文件和我想要的網址'HTTP:// domain.com'那麼應該怎麼需要在.htaccess –

+0

@Irfan見更新變化的答案。我相信會這樣做。 –

+0

夢幻般的 - WP處理404s的條件在底部。我更願意幫助訪客找出他們誤入歧途的地方,並記錄錯誤,以便管理員和他們參與。 WP使用404頁面的唯一時間是被請求的博客文章不存在。我測試了很多東西,這是唯一的404 WP照顧。我想給遊客更多的幫助。非常感謝你! AH - 是否有辦法在這樣的評論中插入換行符?我發現一大堆文本難以閱讀。白色空間有它的位置。 – SimonT