如何在没有404错误的情况下将HTML页面上传到WordPress

Do you want to upload a HTML page to your WordPress site? Sometimes you may need to add a static HTML page and make it accessible along with your WordPress site. In this article, we will show you how to properly upload a HTML page to your WordPress site without causing 404 errors.

您想将HTML页面上传到WordPress网站吗? 有时,您可能需要添加静态HTML页面,并使它与WordPress网站一起访问。 在本文中,我们将向您展示如何正确地将HTML页面上传到WordPress网站,而不会引起404错误。

How to Upload HTML Page to WordPress Site
为什么将HTML页面上传到WordPress? (Why Upload HTML Pages to WordPress?)

WordPress comes with a built-in content type to add pages to your website. Often WordPress themes add pre-designed page templates to display your pages.

WordPress带有内置的内容类型 ,可将页面添加到您的网站。 WordPress主题通常会添加预先设计的页面模板来显示您的页面。

There are even WordPress landing page plugins that allow you to create beautiful page templates with a drag and drop builder.

甚至还有WordPress登陆页面插件 ,可让您使用拖放生成器创建漂亮的页面模板。

This means that in most cases, you shouldn’t need to upload a HTML page to your WordPress site.

这意味着在大多数情况下,您无需将HTML页面上传到WordPress网站。

However, sometimes a user may have static HTML pages from their old website or a static template that they really like and want to use. In these scenarios, you will need to upload your HTML page to WordPress.

但是,有时用户可能会从他们的旧网站上获得静态HTML页面,或者他们真正喜欢并想要使用的静态模板。 在这些情况下,您需要将HTML页面上传到WordPress。

Since, WordPress comes with its own SEO friendly URL structure, it can cause a 404 error if you simply uploaded your HTML page and tried to access it.

由于WordPress带有自己的SEO友好URL结构 ,因此,如果您只是上传HTML页面并尝试访问它,则可能会导致404错误

That being said, let’s take a look at how to upload a HTML page to your WordPress site without causing 404 errors.

话虽如此,让我们看一下如何将HTML页面上传到WordPress网站,而不会导致404错误。

将HTML页面上传到WordPress网站 (Uploading HTML Page to WordPress Site)

Before you upload your HTML page to the WordPress site, you need to make sure that the ‘index.html’ file is renamed to ‘index.php’.

在将HTML页面上传到WordPress网站之前,您需要确保将“ index.html”文件重命名为“ index.php”。

HTML Template File

After that, you need to add all files including the HTML page, CSS, and other folders to a Zip archive.

之后,您需要将所有文件(包括HTML页面,CSS和其他文件夹)添加到Zip存档中。

Windows users can right-click and select Send to » Compressed Zip Folder option to create a zip file. Next, simply drag and drop all files and folders for your HTML page to the zip file.

Windows用户可以右键单击并选择“ 发送到»压缩的Zip文件夹”选项以创建一个zip文件。 接下来,只需将HTML页面的所有文件和文件夹拖放到zip文件中即可。

Zip Archive HTML Page

Mac users can select the parent folder containing all files and folders, and then right-click to select ‘Compress folder’ option.

Mac用户可以选择包含所有文件和文件夹的父文件夹,然后右键单击以选择“压缩文件夹”选项。

Create zip file in Mac

Next, you need to go to the cPanel of your WordPress hosting account. In the cPanel, you need to scroll down to the Files section and then click on the File Manager app.

接下来,您需要转到WordPress托管帐户的cPanel 。 在cPanel中,您需要向下滚动到“ 文件”部分,然后单击“ 文件管理器”应用程序。

Open File Manager

Once you are in File Manager, you need to navigate to the website root folder which is usually called public_html and contains all your WordPress files folders. From there, you need to click on the Folder link from the top menu to create a new empty folder.

进入文件管理器后,您需要导航到网站根文件夹,该文件夹通常称为public_html,其中包含所有WordPress文件文件夹。 在这里,您需要单击顶部菜单中的“ 文件夹”链接以创建一个新的空文件夹。

Create a New Folder

A popup will open where you need to add a name for the new folder. Use a name that you want to use as the URL of your HTML page and then click on the Create New Folder button.

将打开一个弹出窗口,您需要在其中添加新文件夹的名称。 使用您要用作HTML页面URL的名称,然后单击“ 创建新文件夹”按钮。

Create new folder in cPanel

After creating the folder successfully, you need to open it and click on the Upload button from the top menu to select and upload the zip file you created earlier from your computer. You’ll see the progress bar while the zip file uploads to your site.

成功创建文件夹后,需要将其打开,然后单击顶部菜单中的“上载”按钮以选择并上载从计算机上创建的zip文件。 当zip文件上传到您的网站时,您会看到进度栏。

Upload Zipped Template File

Once uploaded, you need to select the zip file and then click on Extract button from the top menu.

上传后,您需要选择zip文件,然后从顶部菜单中单击“ 提取”按钮。

Extract Files

You will be asked where to extract the files. Simply select the same new folder that you created and click on the Extract File(s) button.

系统将询问您将文件解压缩到哪里。 只需选择您创建的相同新文件夹,然后单击“ 提取文件”按钮。

Extract Files in New Folder

File Manager will now extract the zip file, and you will be able to see files in your folder.

文件管理器现在将解压缩该zip文件,您将能够看到文件夹中的文件。

Note: You can now delete the zip file from here. It doesn’t affect your HTML page or any other folders that are extracted.

注意:您现在可以从此处删除zip文件。 它不会影响您HTML页面或任何其他提取的文件夹。

Extracted Folder

Now you can visit this page in the browser by using the name of the folder (For example, yourwebsite.com/example). If your server doesn’t support the redirection, then you may see a 404 error. It happens because your ‘index.php’ file is not redirected on loading the URL in browser.

现在,您可以使用文件夹的名称在浏览器中访问此页面(例如,yourwebsite.com / example)。 如果您的服务器不支持重定向,那么您可能会看到404错误。 发生这种情况是因为在浏览器中加载URL时,“ index.php”文件未重定向。

It is one of the common WordPress errors and can be fixed easily.

这是WordPress常见错误之一 ,可以轻松修复。

Using the File Manager app, you need to edit .htaccess file in your website’s root folder and add the following code:

使用文件管理器应用程序,您需要在网站的根文件夹中编辑.htaccess文件 ,并添加以下代码:



RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,NC,L]


This code will redirect your ‘index.php’ file and load it in the browser. If you are using a case-sensitive name for a file or folder, then the above code will also redirect that to show you the content.

此代码将重定向您的“ index.php”文件并将其加载到浏览器中。 如果您对文件或文件夹使用区分大小写的名称,则上面的代码还将重定向该名称或名称,以向您显示内容。

We hope this article helped you learn how to upload an HTML page to your WordPress site without 404 error. You may want to see our comparison of WordPress vs static HTML to learn which one is better for your business. Also for creating landing pages, we recommend taking a look at the best WordPress drag & drop page builder plugins.

我们希望本文能帮助您学习如何将HTML页面上传到WordPress网站,而不会出现404错误。 您可能需要查看WordPress与静态HTML的比较,以了解哪种更适合您的业务。 另外,对于创建登录页面,我们建议您看看最好的WordPress拖放页面构建器插件

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-upload-a-html-page-to-wordpress-without-404-errors/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值