WordPress 永久链接已损坏
我最近将我的博客从一台服务器转移到另一台服务器。我现在无法恢复我的永久链接结构。
现在我的永久链接结构已变为 /?p=123。每当我尝试将其更改为任何其他自定义永久链接结构时,它都会为所有帖子抛出 404 错误。查看博客:http://microreviews.org 我被迫将永久链接结构设置为 /?p=123。然而,来自搜索引擎的所有条目都位于旧结构 /%postname%/ 上,
相同的插件似乎都不起作用,我坚持使用 ?p=123 结构。
我应该怎么办?
I have recently moved my blog from one serever to another. I am now unable to restore my permalink structure.
Now my permalink strucure has become /?p=123. Whenever, I try to change it to any other custom permalink structure, it throws 404 for all the posts. Check the blog at http://microreviews.org
I have been forced to make the permalink structure as /?p=123. All the entries from search engines are however on the old structure /%postname%/
None of the plugins for the same seem to work and I am stuck with the ?p=123 structure.
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您在 Apache 服务器上:
Assuming you're on Apache server:
另一种选择不是使用 .htaccess(尽管 Wordpress 是围绕修改该文件构建的),您可以获取 .htaccess 文件的内容并将它们添加到 httpd.conf(或虚拟主机配置文件)中的指令中。这种方法需要更多地访问您的 apache 安装(即它可能无法与某些托管解决方案一起使用),但根据 Apache httpd 文档,它更安全并且服务器上的工作更少,因为 apache 每次都会扫描每个目录以查找 .htaccess 文件。页面被访问时,每次访问该页面时,它都会重新加载 .htaccess 文件。如果将访问权限放入服务器配置中,那么它会在 apache 启动时(或服务器重新加载时)加载一次,仅此而已。
例如:
如果您的 .htaccess 文件包含 /www/htdocs/example 目录的以下内容
那么您的 httpd.conf 文件中的以下内容将是等效的
编辑主配置而不是 .htaccess 的方法不需要您将 AllowOverride 指定为其他内容比没有。
在这种情况下,您仍然需要启用 mod_rewrite 才能使永久链接正常工作。
The other option instead of using .htaccess (although Wordpress is built around modifying that file) you can take the contents of the .htaccess file and add them to a directive in your httpd.conf (or virtual host config file). This approach requires more access to your apache installation (i.e. it might not work with some hosting solutions), but according to the Apache httpd documentation it's more secure and less work on the server since apache will scan every directory for .htaccess files each time a page is accessed and it will re-load the .htaccess file(s) every time the page is accessed as well. If the access is put into the server config then it is loaded once at apache start-up (or on a server reload) and that's it.
For example:
If your .htaccess file contained the following for the /www/htdocs/example directory
Then the following in your httpd.conf file would be equivalent
The approach of editing your main configuration instead of .htaccess does not require that you specify AllowOverride to something other than None.
In this case, you'll still need mod_rewrite enabled for permalinks to work correctly.