htaccess 帮助将 Expression Engine 站点迁移到 Wordpress

发布于 2024-11-07 23:59:50 字数 523 浏览 0 评论 0原文

我目前有一个 Expression Engine 博客,我将把它转移到 Wordpress,当前的 url 结构是 /blog/comments/page-title

我已将帖子导入到 Wordpress 中,并且我将保留相同的页面标题漂亮的网址,但只想将地址设置为 /page-title

Wordpress htaccess 文件如下所示,

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

有人可以告诉我如何在此块中执行此附加重定向吗?这也将完全确保搜索引擎索引不会受到影响,因为它已经运行了 4 年,目前我有超过 1700 篇博客文章被索引。

I currently have an Expression Engine blog which I am going to move over to Wordpress, the current url structure is /blog/comments/page-title

I have imported the posts into Wordpress and I'm going to keep the same page title's for the pretty urls but just want the address to be /page-title

the Wordpress htaccess file is as follows

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

can anybody tell me how I do this additional redirect in this block? Also will this totally ensure that search engine indexing won't be affected as it has been running for 4 years and I have over 1700 blog posts currently indexed.

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

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

发布评论

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

评论(1

白日梦 2024-11-14 23:59:50

将其放在 .htaccess 文件中的 WordPress 规则之前:

RedirectMatch ^/blog/comments/(.+)$ /$1 [R=301]

这将重定向 http://yourdomain。 com/blog/comments/my-posthttp://yourdomain.com/my-post,并告诉搜索引擎重定向是永久性的。

需要注意的是:WordPress 不鼓励使用 /%postname%/ 作为永久链接结构,因为它会添加更多查询来确定要加载的内容。来自http://codex.wordpress.org/Using_Permalinks

出于性能原因,强烈不建议使用 %postname% 启动永久链接。

因此,我建议改为使用 /blog/%postname% 之类的内容,在这种情况下,您的规则将如下所示:

RedirectMatch ^/blog/comments/(.+)$ /blog /$1 [R=301]

Put this before your WordPress rules in your .htaccess file:

RedirectMatch ^/blog/comments/(.+)$ /$1 [R=301]

This will redirect http://yourdomain.com/blog/comments/my-post to http://yourdomain.com/my-post, and tell search engines that the redirect is permanent.

One note: WordPress discourages the use of /%postname%/ as a permalink structure as it adds many more queries to determine the content to load. From http://codex.wordpress.org/Using_Permalinks:

Starting Permalinks with %postname% is strongly not recommended for performance reasons.

So I'd suggest instead using something like /blog/%postname% instead, in which case your rule would look like:

RedirectMatch ^/blog/comments/(.+)$ /blog/$1 [R=301]

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