重写规则以切换到子文件夹

发布于 2024-08-25 17:44:22 字数 283 浏览 2 评论 0原文

我正在部署一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身仙ぐ女味 2024-09-01 17:44:22

我不知道这是否适用于你的情况,但是在你的FTP客户端中进行一系列的移动操作不是更简单吗?

  1. 创建目录 /public_html/old/
  2. 将除 /public_html/wp 之外的所有内容移至 /public_html/old
  3. /public_html/ 中的所有内容移至wp 上升一级

完成!

当然,搬家的时候一定要非常小心。

如果这不起作用,我不知道您处于哪种托管环境,但最简单的方法是将您的域映射到 public_html/wp 而不是 public_html。但这无法在 .htaccess 中完成,您将需要对网站设置进行某种访问。

.htaccess 中,您可能必须使用 mod_rewrite 规则,可能看起来像这样(我现在无法测试它,所以没有任何保证。)

RewriteCond %{REQUEST_URI} !^/wp
RewriteRule (.*) /wp/$1?%{QUERY_STRING}

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?

  1. Create directory /public_html/old/
  2. Move everything except for /public_html/wp into /public_html/old
  3. Move everything from /public_html/wp up one level

done!

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 of public_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 a mod_rewrite rule that could look something like this (I can't test this right now so no guarantees.)

RewriteCond %{REQUEST_URI} !^/wp
RewriteRule (.*) /wp/$1?%{QUERY_STRING}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文