仅使用非常特定的模式与 mod_rewrite 匹配 URL

发布于 2024-11-08 14:47:26 字数 1077 浏览 4 评论 0原文

我有一个小问题需要解决。我有两个并行运行的应用程序(CodeIgniter 和 ExpressionEngine),我需要将特定的 URL 模式路由到 CI,将其他所有内容路由到 EE。到目前为止,这基本上是有效的,但有一个小细节。这是我当前拥有的代码:

# Rewrite requests for anything that's not a CI controller or physical file/folder to ExpressionEngine
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !(admin|cron|fst_reporting|playcatch|ppv|purchase|reporting|xml) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

# Route everything else to CodeIgniter
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /app/index.php/$1 [L]

但是,我还想将以下请求推送到

/training
/training/
/training/programme/something
/training/programme/something/

第一个条件块中的 EE,然后将针对一个特定 URL 模式的请求强制发送

/training/something

到 CI 应用程序(如第二个条件块中所示)。

我遇到的问题是尝试将上述要求融入到我现有的条件语句中,理想情况下我想说“任何不等于我的代码点火器控制器或等于/training或/training/programme/something的东西”。同时,我仍然需要能够将对 /training/something(其中某些内容是随机字符串)的请求路由到 CI 应用程序。

有什么想法吗? :)

I have a small problem to solve. I have two applications running side by side (CodeIgniter and ExpressionEngine) and I need to route specific URL patterns to CI and everything else to EE. So far this is mostly working but there's one small detail. Here's the code I currently have:

# Rewrite requests for anything that's not a CI controller or physical file/folder to ExpressionEngine
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !(admin|cron|fst_reporting|playcatch|ppv|purchase|reporting|xml) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

# Route everything else to CodeIgniter
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /app/index.php/$1 [L]

However I also want to push any requests for:

/training
/training/
/training/programme/something
/training/programme/something/

to EE in the first conditional block and then force requests for one specific URL pattern

/training/something

to the CI application (as see in the 2nd conditional block).

The problem I have is trying to blend the above requirements into my existing conditional statement, ideally I want to say "Anything which is NOT equal to my code igniter controllers OR is equal to /training or /training/programme/something". Meanwhile I still need to be able to route requests for /training/something (where something is a random string of characters) to the CI app.

Any ideas? :)

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

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

发布评论

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

评论(1

莫言歌 2024-11-15 14:47:26

也许是这样的:

RewriteBase /
RewriteCond %{REQUEST_URI} ^/training(/)?(/programme/something)?(/)? [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !(admin|cron|fst_reporting|playcatch|ppv|purchase|reporting|xml) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

希望有帮助。

Perhaps something like:

RewriteBase /
RewriteCond %{REQUEST_URI} ^/training(/)?(/programme/something)?(/)? [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !(admin|cron|fst_reporting|playcatch|ppv|purchase|reporting|xml) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

hope that helps.

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