如何在CyberPanel中配置301重定向

要在 CyberPanel 中配置 301 重定向,可以按照以下步骤操作:

  1. 通过CyberPanel面板添加重定向
    • 进入域名管理区域,使用“域名重定向”部分添加您想要转发/重定向的位置2
  2. 使用重写规则
    • 转到 “网站” > “网站列表”,然后点击 “管理” 按钮,向下滚动到 “配置” 部分,找到 “重写规则”5
    • 添加重写规则并点击 “保存重写规则”5
  3. .htaccess 文件
    • 在附加域的文件夹​​中创建一个 .htaccess 文件,并包含以下代码以将 .org 域重定向到 .net4
    textRewriteEngine on RewriteCond %{HTTP_HOST} ^yourdomain.org$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.yourdomain.org$ [NC] RewriteRule ^(.*)$ https://www.otherdomain.net/$1 [L,R=301,NC]
    • 在CyberPanel中,OpenLiteSpeed可能无法读取您通过文件管理器创建的规则。您需要使用子域名启动器来保存子域的重写规则4
  4. 强制将所有请求从 HTTP 重定向到 HTTPS
    • 通过添加以下重写规则,强制重定向所有URL以使用HTTPS5
    textRewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

请记住,在进行任何更改后,您可能需要重新启动 LiteSpeed​​4

Citations:

  1. https://forum.openlitespeed.org/threads/please-help-with-301-redirects-in-htaccess-file.4558/
  2. https://community.cyberpanel.net/t/domain-redirect/43465
  3. https://community.cyberpanel.net/t/how-to-redirect-old-domain-full-content-to-a-new-domain/17528
  4. https://community.cyberpanel.net/t/how-can-i-set-up-an-addon-domain-and-redirect-to-the-main-domain/14594
  5. https://scriptstown.com/how-to-install-wordpress-on-cyberpanel-with-domain-and-ssl/
  6. https://community.cyberpanel.net/t/url-is-redirecting-to-old-domain-after-restoring-a-wordpress-backup-due-to-redis/32294
  7. https://community.cyberpanel.net/t/how-to-redirect-old-domain-full-content-to-a-new-domain/17528/3
  8. https://community.cyberpanel.net/t/tutorial-how-to-make-redirect-with-or-without-www-and-redirect-to-https/14058
  9. https://community.cyberpanel.net/t/the-preview-function-of-the-test-website-keep-redirecting-to-the-old-website-on-another-server/31104
  10. https://community.cyberpanel.net/t/need-help-with-redirecting-specific-url-to-a-different-url-on-main-domain/19955
  11. https://bobcares.com/blog/redirect-http-to-https-cyberpanel/
  12. https://rmalis.com/cyberpanel-redirect-domain-name-to-another-including-urls/
  13. https://community.cyberpanel.net/t/trouble-with-301-redirects-with-cyberpanel-ols/31397
  14. https://community.n8n.io/t/install-n8n-on-docker-in-cyberpanel/14029
  15. https://www.namecheap.com/support/knowledgebase/article.aspx/385/2237/how-to-set-up-a-url-redirect-for-a-domain/
  16. https://community.cyberpanel.net/t/301-redirect-not-working-cyberpanel-ols/35172
  17. https://natsav.com/blog/how-to-manage-multiple-websites-with-cyber-panel/
  18. https://www.inmotionhosting.com/support/website/setting-up-a-301-permanent-redirect-via-htaccess/
  19. https://www.hostinger.com/tutorials/how-to-redirect-a-domain
  20. https://tonyteaches.tech/cyberpanel-redirect-http-to-https/

留下评论