如何在存在静态站点的情况下在根目录中开发WordPress站点?
我可以有一个index2.php 文件并同时重定向htacess 文件吗?如果是这样,我如何暂时重定向页面以便稍后更改?
Can I have an index2.php file and redirect the htacess file for the meantime? If so how do I redirect the page for the time being so I can change it later?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有两种方法可以做到这一点:
将 WordPress 放在其他地方
这是迄今为止创建 WordPress 站点同时保持现有站点处于活动状态的最简单方法。
.hosts
文件,以便您的计算机在您尝试浏览现有网站时指向新位置这类似于我在设置新站点或在客户端系统上工作时使用的过程。如果我的静态站点是
http://mysite.com/
并且位于服务器上的/public_html/mysite.com/
上,我会将 WordPress 停放在中/public_html/wordpress/
并创建一个指向那里的子域 (http://beta.mysite.com/
)。当一切准备就绪后,我只需更改 DNS 设置,一切都会自动进行。在
.htaccess
中设置默认文档如果您现有的站点是静态的,则它的根目录中可能有一个
index.html
文件。您可以告诉您的.htaccess
文件以将此文件用作默认文档。然后,对您网站的常规请求将转到静态网站,但您可以通过将index.php
放在 URL 末尾来手动转到 WordPress。不过,这里要学习的重要教训是,您不应该永远在生产站点上进行开发。您应该在其他地方(在您的计算机本地、子域、子文件夹等)开发您的 WordPress 网站,并且仅在准备好公开时才将其移动到实时网站的根目录。
There are two ways to do this:
Put WordPress somewhere else
This is, by far, the easiest way to create a WordPress site while keeping an existing site active.
.hosts
file so that your computer points to the new location when you try browsing to the existing siteThis is similar to the process I use when setting up a new site or working on a client system. If my static site is
http://mysite.com/
and lives on/public_html/mysite.com/
on the server, I'll park WordPress in/public_html/wordpress/
and create a subdomain that points there (http://beta.mysite.com/
). When everything is ready, I just change my DNS settings and everything moves automatically.Set up your default documents in
.htaccess
If your existing site is static, it's probably got an
index.html
file in the root. You can tell your.htaccess
file to use this as the default document. Then, regular requests to your site will go to the static site, but you can manually go to WordPress by placingindex.php
at the end of your URL.The big lesson to learn here, though, is that you should never develop on a production site. You should develop your WordPress site somewhere else (locally on your computer, on a subdomain, in a subfolder, etc) and only move it to the root of your live site when you're ready for it to go public.
安装在 /dev/ 等子目录中并使用 WordPress 等插件保护网站要容易得多隐私 « WordPress 插件,然后在准备就绪后,将其移至根目录:移动 WordPress « WordPress Codex。 无需重定向或虚拟主机编辑。
Much easier to install in a subdirectory like /dev/ and protect the site with a plugin like WordPress › Absolute Privacy « WordPress Plugins and then when it's ready, move it to root: Moving WordPress « WordPress Codex. No need for redirects or vhosts editing.