mod_rewriting 的乐趣在于两个 .htaccess 文件...一个用于 wordpress,一个用于子目录中的 CI

发布于 2024-09-28 12:13:20 字数 652 浏览 0 评论 0原文

我遇到了一个奇怪的情况,所以我希望有人可以帮助我。

我在根目录中有一个 wordpress 安装,在子目录中有一个 codeigniter 安装(我知道,我知道......)。两者都各自工作得很好。 codeigniter 安装有自己的 .htaccess 文件,用于重写 index.php。

但是,如果我想要将 codeigniter 目录之外的 URL 重写到 codeigniter 目录,然后该目录将由 CI .htaccess 文件再次重写,该怎么办?

例如:

example.com/2010/10/article-title is a URL used by wordpress. THIS WORKS
example.com/codeigniter/ is the root of codeigniter. THIS WORKS
example.com/codeigniter/controller/action is a CI URL. THIS WORKS

但是如果我想指出

example.com/users/list to example.com/codeigniter/users/list 

然后让 CI 正确重写怎么办?

这可以在没有硬重定向的情况下完成吗?

I have a weird situation that's come up, so I'm hoping some one can help me out.

I have a wordpress installation in the root directory and a codeigniter installation in a subdirectory (I know, I know...). Both are working fine on their own. The codeigniter installation has its own .htaccess file for rewriting to index.php.

But what if I wanted a URL outside of the codeigniter directory to rewrite to the codeigniter directory, which will then be rewritten again by the CI .htaccess file.

For example:

example.com/2010/10/article-title is a URL used by wordpress. THIS WORKS
example.com/codeigniter/ is the root of codeigniter. THIS WORKS
example.com/codeigniter/controller/action is a CI URL. THIS WORKS

But what if I wanted to point

example.com/users/list to example.com/codeigniter/users/list 

and then have this be properly rewritten by CI?

Is this possible to do without a hard redirect?

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

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

发布评论

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

评论(1

尐籹人 2024-10-05 12:13:20

在您的根目录 .htaccess 中上方写入 WordPress 规则:

RedirectMatch Permanent ^/users/(.*) /codeigniter/users/$1

In your root directory .htaccess write above the WordPress rules:

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