需要帮助了解.htaccess文件的内容

时间:2015-12-15 05:27:43

标签: php wordpress .htaccess

我正在使用Wordpress在博客上工作,我无法弄清楚它创建的.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

有谁了解这个有时间向我解释每一行?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分: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>