dqef7931 2017-01-21 02:04
浏览 81
已采纳

将WordPress永久链接重定向到简单的帖子名称

I want to 301 redirect my entire WordPress money site from https:// moneysite.com/%category%/%postname%/ to simply https:// moneysite.com/%postname%/ , but exclude everything in a CPT called 'team' which uses the permalink like https://www.moneysite.com/team/rogger/. I have googled for this, but didn't come up with anything, or I didn't think what I saw was right.

I also want to redirect http to https and remove the www from the permalink. Please guide me a bit. It will be very helpful for me as i am spending countless hours in setting this up.

I got a code but it's not excluding and removing permalink "Team" from the pages as well.

RedirectMatch 301 ^/([^/]+)/([^/]+)/$ https://moneysite.com/$2
  • 写回答

2条回答 默认 最新

  • dsc71976 2017-01-21 02:13
    关注

    This will exclude team (and make the last forward slash optional):

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/team/
    RewriteCond %{REQUEST_URI} !^/products/
    RewriteRule ^([^/]+)/([^/]+)/?$ https://moneysite.com/$2 [L,R=301]
    

    This goes just after it and will remove www and/or redirect to HTTPS:

    RewriteCond %{HTTP_HOST} !=moneysite.com [OR]
    RewriteCond %{HTTPS} =off
    RewriteRule ^ https://moneysite.com%{REQUEST_URI} [L,R=301]
    

    To go in root .htaccess file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程