重写规则以切换到子文件夹
我正在部署一个 Wordpress 博客,但我还不想覆盖当前站点。
public_html/. <-- 当前站点
public_html/wp/. <-- 新站点
我的 .htaccess 必须是什么样子,以便我可以从当前站点到新站点 这样 http://domain.tld 显示新网站,就像直接在 public_html 文件夹中一样
I'm deploying a Wordpress blog, but I don't want to overwrite the current site yet.
public_html/. <-- the current site
public_html/wp/. <-- the new site
How must my .htaccess look like so I can seamlessly switch from the current site to the new one
so that http://domain.tld shows the new site like it would be directly in the public_html folder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否适用于你的情况,但是在你的FTP客户端中进行一系列的移动操作不是更简单吗?
/public_html/old/
/public_html/wp
之外的所有内容移至/public_html/old
/public_html/ 中的所有内容移至wp
上升一级完成!
当然,搬家的时候一定要非常小心。
如果这不起作用,我不知道您处于哪种托管环境,但最简单的方法是将您的域映射到
public_html/wp
而不是public_html
。但这无法在.htaccess
中完成,您将需要对网站设置进行某种访问。在
.htaccess
中,您可能必须使用mod_rewrite
规则,可能看起来像这样(我现在无法测试它,所以没有任何保证。)I don't know whether it applies to your situation, but wouldn't it be simpler to just do a series of move operations in your FTP client?
/public_html/old/
/public_html/wp
into/public_html/old
/public_html/wp
up one leveldone!
You'd have to be very careful when doing the moving of course.
If that won't work, I don't know what kind of hosting environment you are in, but the easiest way to do would be to map your domain to
public_html/wp
instead ofpublic_html
. That can't be done in.htaccess
though, you will need some kind of access to the site's setup.In
.htaccess
, you will probably have to use amod_rewrite
rule that could look something like this (I can't test this right now so no guarantees.)