【发布时间】:2013-04-04 01:10:13
【问题描述】:
我知道如何从 CI url 中删除 index.php。以下工作正常:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /crm/v2/index.php?/$1 [L]
但是,它会干扰实时站点上的其他代码。我要添加的这个新 CI 版本位于名为 v2 的子目录中。因此布局类似于:
-originalDir
--v2
-otherDirs
-.htaccess
-etc...
所以本质上 url 会出现这样的结果:
// Original page
https://www.site.com/originalDir/somepage.htm
// And this exist too
https://www.site.com/originalDir/index.php
// My new stuff
https://www.site.com/originalDir/v2/index.php/controller/etc...
// Desired effect withOUT affecting the original sites index.php page
// aka, the below is what i WANT but NOT getting!
https://www.site.com/originalDir/v2/controller/etc...
我可以用多种语言编写代码,但对这些 htaccess 重写没有太多经验。关于如何使其仅为 codeigniter 子目录重写 index.php 的任何想法?我尝试了一些似乎在本地工作的东西,但在实时服务器上却不行。不确定重写代码的确切结构。
【问题讨论】:
-
您的 htaccess 实际上看起来不错,您是否从 config.php 文件中删除了 index.php?
-
这是正确的,正如我之前所说,但是在同一个站点上有停止工作的旧代码。因此我需要一个替代解决方案。
-
是的,但我的意思是它看起来并不应该影响高于该级别的任何内容。尽管如此,我对 htaccess 也不是很好......
-
@RickCalder NP,感谢您的询问。我在下面找到了答案。将替代解决方案放在 v2 目录中似乎完全符合我的预期,并且不会影响网站的其余部分!
标签: .htaccess codeigniter rewrite