WordPress 会做一些覆盖 .htaccess 的事情吗?

发布于 2024-10-26 00:26:57 字数 654 浏览 1 评论 0原文

我正在本地为客户开发 WordPress 网站。客户端将 WordPress 的安装保留在服务器根目录中,但因为我有多个客户端,所以我喜欢将所有内容安装在客户端文件夹中,例如 localhost/client。通常,向 .htaccess 添加重写规则很简单,将重写基设置为 /client/。但今天它根本不起作用。即使我在重写规则中添加了无意义的内容,该站点也可以正常工作(如果重写规则有效,则不应如此)。图像引用仍在 localhost/ 上查找根目录,而不是 localhost/client/,这意味着它们已损坏。

我查看了 WordPress 的文档,发现它有一个名为 WP_rewrite 的东西,并且在 wp-includes/rewrite.php 中有一个为其设置参数的地方)。我将 root 参数设置为 client/ 但这似乎也没有任何效果。

最后一件事:在 localhost/client/ 中有一个 .htaccess 文件,在 localhost/client/wp/ 中有另一个文件。我将它们都设置为 RewriteBase = /client/,但我尝试了几乎所有其他合理的组合 - 没有改变。

所以我的问题是:WordPress 是否会执行其他操作,导致我在 .htaccess 中设置的重写规则不起作用?

I'm working locally on a WordPress site for a client. The client keeps their install of wordpress in the server root, but because I have more than one client, I like to install everything in a client folder, like localhost/client. Normally it's a simple matter to add a rewrite rule to .htaccess, setting the rewrite base to be /client/. But today it's not working at all. Even if I put nonsense in the rewrite rule, the site works (which it should not, if the rewrite rules are in effect). The images references are still looking for root at localhost/, instead of localhost/client/, which means they are broken.

I looked into WordPress's documentation and found it has something called WP_rewrite, and there is a place to set parameters for it in wp-includes/rewrite.php). I set the root parameter to client/ but that doesn't seem to have any effect either.

One last thing: there is an .htaccess file in localhost/client/, and another one in localhost/client/wp/. I have them both set to RewriteBase = /client/, but I've tried just about every other sensible combination--no change.

So my question is: does WordPress do something else that would make the rewrite rules I set in .htaccess not work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

深者入戏 2024-11-02 00:26:57

我建议对您的本地环境进行一些小的更改,以获得更灵活的解决方案。使用虚拟主机。如果您正在运行 WAMP/MAMP,则可以轻松使用此工具。它允许您在本地主机中运行一个目录作为其自己的站点,您可以使用您选择的仅限本地的 URL 访问该目录。例如,我将我的网站设置为 sitename.local,因此它们都生活在自己快乐的小生态系统中。强烈推荐。

I'd recommend a small change to your local environment for a more flexible solution. Use virtual hosts. If you're running WAMP/MAMP, this tool is readily available to you. It allows you run a directory within your localhost as its own site, which you can access using a local-only URL of your choosing. I have my sites set up as sitename.local, for instance, so they all live in their own happy little ecosystem. Highly recommended.

好菇凉咱不稀罕他 2024-11-02 00:26:57

是的,您必须执行一些步骤来更改数据库中的条目,然后才能将其移动到子文件夹。
以下是详细信息:
http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Within_Your_Site

您需要执行的操作:

  1. 复制所有内容因为它是在您的客户端服务器上设置的,即在根文件夹中,所以
  2. 请执行上述 url 中的步骤,重要的是 4。 5.;步骤10.实际上只需转到永久链接设置并单击“保存”按钮(或“更新”我不记得它是怎么说的)

现在你可以工作了:)
你是只修改主题还是什么?

Yes it does, you have to make some steps that will change entries in db before you move it to subfolder.
Here are detailed info:
http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Within_Your_Site

What you need to do:

  1. copy everything as it is setup on your clients server i.e. in root folder
  2. do the steps in above url, important are 4. & 5.; step 10. actually just go to permalink settings and click on "Save" button (or "Update" I do not remember how it says)

Now you can work :)
Are you modifying only theme or what?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文