
.htaccess 文件
您在 WordPress 中查找 .htaccess 文件时遇到问题吗?初学者经常问我们“我的 .htaccess 文件在哪里?”和“为什么我在 WordPress 网站上找不到它?”。
您在 WordPress 中找不到 .htaccess 文件吗?初学者经常问我们“.htaccess 文件在哪里?”和“为什么我在我的 WordPress 网站上找不到它?”。
Sometimes you may need to edit the .htaccess file or delete it to fix a WordPress 常见错误. In this article, we will explain why you can’t find .htaccess file on your WordPress site, and how to easily locate it.
有时您可能需要编辑.htaccess文件或将其删除以修复WordPress 常见错误 。 在本文中,我们将解释为什么您无法在WordPress网站上找到.htaccess文件,以及如何轻松找到它。

什么是.htaccess文件? (What is .htaccess file?)
The .htaccess file is a server configuration file which tells your server how to handle certain things on your website. Like how to redirect users, 密码保护管理区域, or 保护一些目录, etc.
.htaccess文件是服务器配置文件,它告诉服务器如何处理网站上的某些内容。 像如何重定向用户一样,用受密码保护的管理员区域或保护某些目录等。
它位于 WordPress 网站的根文件夹中。 WordPress 使用它来管理重定向和永久链接。
它位于 WordPress 网站的根文件夹中。 WordPress 使用它来管理重定向和永久链接。
The .htaccess file is an incredibly powerful configuration file and can be used to do a lot useful things. See our article on the WordPress 最有用的 .htaccess 技巧 for some examples.
.htaccess文件是一个功能非常强大的配置文件,可以用来做很多有用的事情。 有关某些示例,请参阅我们关于最有用的 WordPress .htaccess 提示文章。
为什么找不到.htaccess文件? (Why I Can’t Find .htaccess File?)
在网站的根文件夹中找不到 .htaccess 文件有两个常见原因。它要么被文件管理器软件隐藏,要么根本不存在。
在网站的根文件夹中找不到 .htaccess 文件有两个常见原因。它要么被文件管理器软件隐藏,要么根本不存在。
我们将用解决方案来解释它们。
我们将用解决方案来解释它们。
1.您的FTP客户端未显示隐藏文件 (1. Your FTP Client is Not Showing Hidden Files)
The dot before the htaccess file name indicates that it is a hidden file. By default, when you connect to your WordPress 托管服务器 using an FTP client, it will not show the hidden files.
htaccess文件名前面的点表示它是一个隐藏文件。 默认情况下,当您使用FTP客户端连接到托管 WordPress 服务器时 ,它不会显示隐藏文件。
要使隐藏文件可见,您需要更改 FTP 客户端设置。
要使隐藏文件可见,您需要更改 FTP 客户端设置。
例如,在 FileZilla 中,您可以在“服务器 » 强制显示隐藏文件”菜单下找到该选项。
例如,在 FileZilla 中,您可以在“服务器 » 强制显示隐藏文件”菜单下找到此选项。

如果您在 cPanel 中使用文件管理器应用程序,那么您将找到在启动应用程序之前显示隐藏文件的选项。
如果您在 cPanel 中使用文件管理器应用程序,那么您将找到在启动应用程序之前显示隐藏文件的选项。

对于其他 FTP 客户端,您将在应用程序设置或首选项菜单中找到显示隐藏文件的选项。
与其他 FTP 客户端一样,您可以在应用程序设置或首选项菜单中找到显示隐藏文件的选项。
启用此选项后,您将能够查看 WordPress 站点的所有隐藏文件,包括 .htaccess 文件。
启用此选项后,您将能够查看 WordPress 网站的所有隐藏文件,包括 .htaccess 文件。
2. .htaccess文件不存在 (2. The .htaccess File Doesn’t Exist)
丢失 .htaccess 文件的第二个最常见原因是您的 WordPress 网站尚未生成该文件。
丢失 .htaccess 文件的第二个最常见原因是您的 WordPress 网站尚未生成该文件。
WordPress automatically generates .htaccess file because it is required to properly redirect 永久链接.
WordPress自动生成.htaccess文件,因为正确重定向永久链接是必需的。
If your .htaccess file is missing, then the first thing you need to do is to visit 设置 » 固定链接 page and click on ‘Save Changes’ button without changing anything.
如果您的.htaccess文件丢失,那么您要做的第一件事是访问“设置”»“固定链接”页面,然后单击“保存更改”按钮,而不进行任何更改。

WordPress 现在将尝试为您生成 .htaccess 文件。
WordPress 现在将尝试为您生成 .htaccess 文件。
在极少数情况下,WordPress 可能由于文件权限问题而无法生成 .htaccess 文件。
在极少数情况下,WordPress 可能由于文件权限问题而无法生成 .htaccess 文件。
In that case, it will show you a message at the bottom of the 设置 » 固定链接 page, saying that the ‘.htaccess file is not writeable’.
在这种情况下,它将在“设置”»“固定链接”页面底部显示一条消息,提示“ .htaccess文件不可写”。
您需要手动创建 .htaccess 文件并在其中添加所需的代码。
您需要手动创建 .htaccess 文件并在其中添加所需的代码。

只需将此代码复制并粘贴到记事本等文本编辑器中即可。之后,您需要将其另存为桌面上的 .htaccess 文件。
只需将此代码复制并粘贴到文本编辑器(例如记事本)中即可。之后,您需要将其另存为桌面上的 .htaccess 文件。
现在使用 FTP 客户端连接到您的网站并从桌面上传 .htaccess 文件。
现在,使用 FTP 客户端连接到您的网站并从桌面上传 .htaccess 文件。
If you get an error while uploading the file, then you need to 更改文件权限 for your root directory.
Let’s suppose all your WordPress files reside under /home/johnsmith/public_html/
directory.
假设您所有的WordPress文件都位于/home/johnsmith/public_html/
目录下。
This makes public_html
folder your root directory. You need to go to its parent directory and right click on the public_html
folder. Select 文件权限, which will open a file permissions dialog box.
这使public_html
文件夹成为您的根目录。 您需要转到其父目录,然后右键单击public_html
文件夹。 选择文件权限 ,这将打开一个文件权限对话框。
现在在文件权限对话框中输入 755,然后尝试将 .htaccess 文件上传到 public_html 文件夹。
现在在文件权限对话框中输入 755 并尝试将 .htaccess 文件上传到 public_html 文件夹。

We hope this article helped you find .htaccess file on your WordPress site. You may also want to see our WordPress 故障排除指南 to learn how to diagnose and fix WordPress issues all by yourself.
我们希望本文能帮助您在WordPress网站上找到.htaccess文件。 您可能还想查看我们的WordPress 故障排除指南,以了解如何自行诊断和修复WordPress问题。
If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/beginners-guide/why-you-cant-find-htaccess-file-on-your-wordpress-site/
.htaccess 文件