【发布时间】:2010-06-29 03:25:19
【问题描述】:
我确信这可能真的很简单,但是我在这方面的知识确实不好,而且我似乎无法正确理解。
我的文件结构如下:
/cms (renamed from system)
cms.php (renamed from index.php, added to DirectoryIndex in .htaccess)
.htaccess
index.html
page1.html
/css
/js
我也有来自 CI wiki 的 .htaccess。我认为需要调整的部分是:
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to cms.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ cms.php?/$1 [L]
我希望大多数已经存在的文件都可以访问,例如和 .js、.css、.png、.swf 等,但任何 .htm 或 .html 都将由 cms.php 处理。
例如,如果用户请求http://localhost/index.html,则将index.html 传递给cms.php,或者如果请求http://localhost/dir/page.html,则传递dir/page.html。
【问题讨论】:
-
出于好奇,您所拥有的有什么不妥之处?
-
它工作得很好,但我试图捕获 html 文件以在输出之前处理它们。例如,用户请求 index.html,“index.html”被传递给加载文件的 codeigniter 应用程序,进行任何更改,然后回显内容。需要它以这种方式工作以保持简单 - 设计人员只需在其代码中转储 3 个文件(/cms、cms.php 和 .htaccess)即可对其进行 cms 化。
-
啊,我明白了。 (我知道这个问题的原始答案存在问题,但在我确定你想要什么之前不想发布答案,看起来你已经弄清楚了,很高兴听到它的工作!)跨度>
标签: .htaccess mod-rewrite codeigniter