gpt4 book ai didi

php - 如何在 Htaccess 中编写多个规则

转载 作者:可可西里 更新时间:2023-11-01 01:06:28 24 4
gpt4 key购买 nike

我正在为我的网站使用 codeigniter 框架,我还有一个博客网站,它是在 wordpress 中完成的。我的网站网址是这样的 https://mydomain.com 我的博客网址是 https://mydomain.com/blog。我像这样为我的网站编写了 htaccess

重写规则 ^([^.]+)$ index.php/profile/fundraiser/$1

每当我使用我的博客网站时,它总是重定向到配置文件 Controller (在 htaccess 中定义)。如果 url 是 https://mydomain/blog 它应该重定向到我的博客,在其他情况下它应该重定向到配置文件 Controller 。我是否可以为此编写多个 Htaccess 规则,因为我已将两个文件放在同一个域中?任何人都请帮助我。

最佳答案

你必须像下面这样使用重写条件 -

RewriteCond $1 !^(blog)
RewriteRule ^([^.]+)$ index.php/profile/fundraiser/$1

即只有当 URL 不包含博客时,它才会重定向到个人资料页面。您可以为每个规则添加更多条件。

关于php - 如何在 Htaccess 中编写多个规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9748738/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com