我相信这可能很简单,但我的知识在这方面确实不太好,而且我似乎也没有把它做好。Mod重写* .html文件(CodeIgniter)
我有以下文件结构:
/cms (renamed from system)
cms.php (renamed from index.php, added to DirectoryIndex in .htaccess)
.htaccess
index.html
page1.html
/css
/js
我也有从CI维基的.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。
出于好奇,什么不正确与你有什么? – 2010-06-28 19:15:01
它的工作原理,但我试图捕捉HTML文件来处理它们之前输出。例如,用户请求index.html,“index.html”被传递给codeigniter应用程序,该应用程序加载文件,进行任何更改,然后回显内容。需要它以这种方式工作以保持简单 - 设计者只需要将3个文件(/ cms,cms.php和.htaccess)转储到cms中即可。 – Josh 2010-06-28 19:23:59
啊,我现在明白了。 (我知道这个问题的原始答案有问题,但不想在我确定你想要什么之前发布答案,看起来你已经知道了,但很高兴听到它的工作!) – 2010-06-28 19:49:33