Tutorial :Mod Rewrite to rewrite *.html files (CodeIgniter)


I'm sure this is probably really simple, but my knowledge really isn't good in this area, and I don't seem to be able to get it right.

I have the following file structure:

/cms (renamed from system)  cms.php (renamed from index.php, added to DirectoryIndex in .htaccess)  .htaccess  index.html  page1.html  /css  /js  

I also have the .htaccess from the CI wiki. The part I think needs adjusting is:

#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]  

I want most files that already exist to be accessible, e.g. and .js, .css, .png, .swf etc, but any .htm or .html to be processed by cms.php.

For example, if the user requests http://localhost/index.html, index.html gets passed to cms.php, or if http://localhost/dir/page.html is requested, dir/page.html is passed.


<IfModule mod_rewrite.c>  RewriteEngine on  RewriteCond $1 !^(*\.js|*\.png|*\.css|*\.swf|folder1|folder2)  RewriteRule ^(.*)$ index.php/$1   RewriteRule ^.\.htm cms\.php  RewriteRule ^.\.html cms\.php  </IfModule>  

you can add other extensions and/or folders that you do not want re-directed to the RewriteCond line.


Found a tutorial, and came up with the following:

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

So anything requested ending in .html is passed to cms.php, resulting in a URL like cms.php/index.html, which cms.php can process and output.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »