Welcome Guest, Not a member yet? Register   Sign In
Mod Rewrite to rewrite *.html files
#1

[eluser]joshbuckley[/eluser]
Hi, I'm developing a CMS with CI, and am having trouble getting the correct rewrite settings.

My directory structure is as follows:

Code:
/cms (renamed from system)
cms.php (renamed from index.php, added to DirectoryIndex in .htaccess so its loaded first)
.htaccess
index.html
page1.html
/css
/js

Now, what I want to do is have a designer do all their html/css/js etc, however they like, and be able to dump in the /cms, cms.php and .htaccess in the same directory to automatically CMS-ify the site.

So, I need all html documents, ie index.html and page1.html, plus those in subfolders (except the cms folder) to be processed by CI.

I have a route in CI that routes all requests ending in .htm or .html to an appropriate controller, which can load and process the file then output its contents.

However, when an html file is currently accessed, CI doesn't get involved - this is because I'm using the .htaccess from the wiki - which allows access to any files which exist.

Code:
#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 jbcms.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ cms.php?/$1 [L]

I need this to continue, with the exception of .htm and .html files which need processing. I'm guessing I need a RewriteCond below the two listed which excludes these files. I've had a go at doing it myself, but its not my strong point and I didn't get anywhere Smile

Any help would be much appreciated!
#2

[eluser]joshbuckley[/eluser]
As usual, after posting, I find the solution fairly quickly!

Came up with this:

Code:
RewriteRule ^(.*\.html)$ cms.php?/$1 [NC]

Incredibly simple.




Theme © iAndrew 2016 - Forum software by © MyBB