【问题标题】:wordpress the_permalink() breaks when wp home and site home are different当 wp home 和 site home 不同时,wordpress the_permalink() 会中断
【发布时间】:2012-08-22 17:24:47
【问题描述】:

我在一个子文件夹中安装了 Wordpress 的网站。如果我使用默认设置,即常规设置的 WordPress 地址和站点地址字段中的条目相同,例如http://localhost/mysite/wordpress,一切都很好。但是,如果我将站点地址更改为站点根目录 (http://localhost/mysite),则 WP 中使用 the_permalink() 函数的每个链接都会失败,并且我会得到像 http://localhost/mysite/?p=181 这样的链接,而不是像 http://localhost/mysite/wordpress/?p=181 这样的链接。

我该如何解决这个问题?

谢谢 - 乔

【问题讨论】:

  • 将内联代码sn-ps包裹在`符号中。

标签: wordpress


【解决方案1】:

更改站点地址后,您必须将 .htaccess 和 index.php 文件复制到一个目录(在您的情况下,将它们复制到 [code]http://localhost/mysite //[/code]) 然后编辑 index.php 文件替换

require('./wp-blog-header.php');

require('./wordpress/wp-blog-header.php');

您可以在http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install找到有关如何执行此操作的完整说明

【讨论】:

  • 这不是我想要做的。我有一个现有的 HTML 站点,我想将 WP 作为博客和相关页面添加到它自己的目录中。任何想法如何让 the_permalink() 在这种情况下正常工作?
【解决方案2】:

从你所说的来看,我认为这是你的 .htaccess。

您需要将子目录添加到 RewriteBase 和 RewriteRule。

所以在普通的WordPress SEO permalink htaccess中替换下面两行就好了;

RewriteBase /your-subdirectory/

还有:

RewriteRule . /your-subdirectory/index.php [L]

【讨论】:

  • 我尝试实施您的解决方案,但似乎没有什么不同。我假设您还需要将常规设置站点 URL 值更改为我的站点根目录。这不正确吗?
  • 不,我只是将常规设置中的这两个站点设置都设置为子目录路径。您不必更改根目录中的任何内容,如果您像我说的那样将其添加到 htaccess 中,WP 通常在子目录中运行没问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多