htaccess 帮助将 Expression Engine 站点迁移到 Wordpress
我目前有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其放在 .htaccess 文件中的 WordPress 规则之前:
RedirectMatch ^/blog/comments/(.+)$ /$1 [R=301]
这将重定向
http://yourdomain。 com/blog/comments/my-post
到http://yourdomain.com/my-post
,并告诉搜索引擎重定向是永久性的。需要注意的是:WordPress 不鼓励使用
/%postname%/
作为永久链接结构,因为它会添加更多查询来确定要加载的内容。来自http://codex.wordpress.org/Using_Permalinks:因此,我建议改为使用
/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
tohttp://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: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]