1

Hello stackoverflow community,

I've got a little Problem with my CodeIgniter. I use two applications in my app folder. The first one is the frontend, the second one the backend.

In my root directory I've two .php files. An index.php leading to the frontend directory and a backend.php leading to the backend directory.

Since I use mod rewrite in order to get clean URL's there is a problem with that. The URL structure is the following: www.domain.com/controller/action

That's the action of the controller in my frontend Application.

I use htacces to get rid of the /index.php/ between domain and controller. To access my backend application I want my URL to be like this www.domain.com/admin/controller/action

therefore I have this rewrite rule:

RewriteCond %{REQUEST_URI} ^admin.*
RewriteRule ^admin/(.*)$ /backend.php?/$1 [L]

Now the problem: CodeIgniter assumes that /backend/ is the first URI segment, and wants to treat it mistakenly as my controller.

Do I really have to edit the core of CodeIgniter in order to tell it not to use the Server Request URI or is there another trick?

Thanks in advance, Thomas

4

2 回答 2

1

这真的行不通。查看 config/config.php 和 config/settings.php 等以获取需要设置的常量...您确实需要在单独的“应用程序”目录中运行每个应用程序。同样值得问问自己它们是否需要“单独”的应用程序......

基本上,在你还可以的时候停止走这条路,它会导致心碎和大量可怕的代码。

于 2011-06-03T15:58:31.770 回答
0

我建议不要在控制器中有一个名为“admin”的文件夹,而不是有两个应用程序文件夹,您还可以在您的modelsviews甚至libraries)名为“admin”的文件夹中创建文件夹,然后您可以将其拉出该项目并移至其他项目。

这将允许您仅使用标准从 URLrewrite中删除,并指向控制器中的管理文件夹。index.phpdomain.com/admin

您只需要确保在根控制器文件夹中没有名为“admin.php”的控制器,否则您会遇到问题。

有关更多信息,请查看:将您的控制器组织到CI 文档中的子文件夹中。

另请注意,开箱即用的 MVC 框架可能并不总是最适合用于创建 CMS。通常,MVC 框架最适合用于快速创建具有相当静态routes指向特定controllers. 另一方面,CMS 倾向于完全控制网站,这导致数据库驱动的路由通常消除对典型的需求,controllers除非你有一个经过大量修改的路由系统。

于 2011-06-03T17:15:57.933 回答