wordpress 本地wordpress安装只显示主页,所有其他页面未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17622560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Local wordpress install only shows home page, all other pages Not Found
提问by Ty Underwood
I am working on a local install of a live wordpress site, all links from the main page show Not Found errors. all .htaccess files are all present.
我正在本地安装一个实时 wordpress 站点,主页上的所有链接都显示未找到错误。所有 .htaccess 文件都存在。
The problem is that every page except for the home page is showing a Not Found error, I can't find any problems with permissions or anything else that would cause it to not work.
问题是除了主页之外的每个页面都显示未找到错误,我找不到任何权限问题或其他任何会导致它无法工作的问题。
Is there anything that I can try that I might be overlooking? I apologize for the vauge questions but I am having trouble figuring out where to start.
有什么我可以尝试但我可能会忽略的东西吗?我为 vauge 问题道歉,但我无法弄清楚从哪里开始。
回答by Ennui
Log in to the admin panel (localhost/sitedirectory/wp-admin) and go to Settings->Permalinksand click Save Changes. Permalinks often need to be rebuilt after mirroring a site and updating the site url. You don't need to change any settings, just hit save and it will rebuild the permalinks with the selected options.
登录到管理面板 (localhost/sitedirectory/wp-admin) 并转到Settings->Permalinks并单击Save Changes。永久链接通常需要在镜像站点并更新站点 url 后重建。您不需要更改任何设置,只需点击保存,它将使用所选选项重建永久链接。
Also make sure the Apache module mod_rewrite
is enabled on your local stack. IIRC WAMP (and possible XAMPP) do not enable this by default. Doing so in WAMP is as simple as clicking the WAMP icon in the taskbar, then going to Apache -> Apache Modules -> mod_rewrite (click to toggle) and then restart all services.
还要确保mod_rewrite
在您的本地堆栈上启用了 Apache 模块。IIRC WAMP(和可能的 XAMPP)默认不启用此功能。在 WAMP 中这样做就像单击任务栏中的 WAMP 图标一样简单,然后转到 Apache -> Apache 模块 -> mod_rewrite(单击切换),然后重新启动所有服务。
Also I am assuming you already updated the site and home urls (either in the wp_options
database table or in wp-config.php
). For reference there is a Codex page about this: Moving Wordpress
此外,我假设您已经更新了站点和主页 url(在wp_options
数据库表中或在 中wp-config.php
)。作为参考,有一个关于此的 Codex 页面:Moving Wordpress
回答by Steele Rocky
You can do it in a really simple way. Just go to
你可以用一种非常简单的方式来做到这一点。就去
Settings >> Permalinks >>
and click "save changes" without changing anything.
Settings >> Permalinks >>
并单击“保存更改”而不更改任何内容。
If it gives you .htaccess file permission issue, you need to set privilege of your ROOT folder (where your wp-content folder lies) to read and write.
如果它给你 .htaccess 文件权限问题,你需要设置你的 ROOT 文件夹(你的 wp-content 文件夹所在的位置)的权限来读写。
And again go to
再去
Settings >> Permalinks >>
and click "save changes" without changing anything.
Settings >> Permalinks >>
并单击“保存更改”而不更改任何内容。
That's all. Hope it resolves the issue.
就这样。希望它能解决问题。
回答by Nilesh Modak
Please enable rewrite_module
. To enable it on windows wampfollow these click on wamp -> Apache ->Apache Module -> check rewrite_module
请启用rewrite_module
。要在 windows wamp上启用它,请按照这些点击wamp -> Apache ->Apache Module -> check rewrite_module
回答by Pedz
Thought I would just add to this as I was experiencing the same issue but I was unable to access wp-admin to make the update to the permalink.
我以为我会添加到这个,因为我遇到了同样的问题,但我无法访问 wp-admin 来更新永久链接。
Be sure to edit your database under wp_options for the siteurl to mirror your localhost. I actually found that even though I did this it didn't solve my issue so I placed the following lines in the wp-config file:
请务必在 wp_options 下编辑您的数据库,以便 siteurl 镜像您的本地主机。我实际上发现即使我这样做了它也没有解决我的问题所以我在 wp-config 文件中放置了以下几行:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Once I added these lines I was able to login via wp-admin or wp-login.php and update the permalinks as described in the answer listed.
添加这些行后,我就可以通过 wp-admin 或 wp-login.php 登录并按照列出的答案中的描述更新永久链接。
回答by Isa
Apache -> Apache modules -> rewrite_module
and make sure this is ticked.
Then save changes to permalinks.
Apache -> Apache modules -> rewrite_module
并确保勾选此项。然后保存对永久链接的更改。
回答by Sebastien
Another thing is you may have to change your .htaccess. For example, I mirrored my site locally, but in a subfolder, I had to change my .htaccess, but Wordpress gives you the code you need :
另一件事是您可能需要更改您的 .htaccess。例如,我在本地镜像了我的站点,但在子文件夹中,我不得不更改我的 .htaccess,但 Wordpress 为您提供了所需的代码:
Settings -> Permalinks -> See at the bottom of the page.
设置 -> 固定链接 -> 见页面底部。
Anyway, the provided code needs mod_rewriteto work properly, so combine this answer with the previous ;)
无论如何,提供的代码需要mod_rewrite才能正常工作,因此请将此答案与之前的答案结合起来;)
回答by Dan
Save permalinks does solve this most of the time, but if you happen to have just moved machines and installed new copy of MAMP theres one other thing to check. In addition to updating hosts and vhosts and all that (for multiple site w/ custom domain setup), don't forget to open MAMP -> preferences -> web server -> apache and make sure you have the document root to where it was on your old machine instead of default /htdocs/! Thats what solved it for me. Props to answer above that mentioned AllowOverride directive, its only when i saw that in http.conf I noticed document root was off. I think you could just edit it http.conf directly but in case MAMP used it for anything else i went ahead and just made the change in MAMP prefs.
Save permalinks 确实在大多数情况下解决了这个问题,但是如果您碰巧刚刚移动了机器并安装了 MAMP 的新副本,那么还有一件事需要检查。除了更新主机和虚拟主机以及所有这些(对于具有自定义域设置的多个站点),不要忘记打开 MAMP -> 首选项 -> Web 服务器 -> apache 并确保您将文档根目录指向它所在的位置在你的旧机器上而不是默认的 /htdocs/! 这就是为我解决的问题。回答上面提到的 AllowOverride 指令的道具,只有当我在 http.conf 中看到它时,我才注意到文档根目录已关闭。我认为你可以直接编辑它 http.conf 但如果 MAMP 将它用于其他任何事情,我会继续并在 MAMP 首选项中进行更改。
回答by ow3n
The solution involved a combination of multiple answers from this page:
该解决方案涉及此页面中多个答案的组合:
- Change apache's
AllowOverride
directive toAll
in your http config. - Restart Apache
- Go to Settings->Permalinks and click Save Changes
- 将 apache 的
AllowOverride
指令更改为All
在您的 http 配置中。 - 重启阿帕奇
- 转到设置->固定链接,然后单击保存更改