WordPress 会做一些覆盖 .htaccess 的事情吗?
我正在本地为客户开发 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议对您的本地环境进行一些小的更改,以获得更灵活的解决方案。使用虚拟主机。如果您正在运行 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.
是的,您必须执行一些步骤来更改数据库中的条目,然后才能将其移动到子文件夹。
以下是详细信息:
http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Within_Your_Site
您需要执行的操作:
现在你可以工作了:)
你是只修改主题还是什么?
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:
Now you can work :)
Are you modifying only theme or what?