EllisLab text mark
Advanced Search
     
adding html extension
Posted: 10 May 2009 09:41 AM   [ Ignore ]
Joined: 2009-05-10
4 posts

I want to add .html extension behind some of the files of my site.As i have used codeigniter utility html that adds html extension behind all files.So i want any rewrite rule or configuration in CI to add html extension to limited or only required files.

 
Posted: 10 May 2009 10:45 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2006-08-26
660 posts

If I understand right, then You have some static html files which You want to show directly, only if the file does not exist, You want to use Your CI installation.

You can use this .htaccess file, it’s not specially written for Yous case, but it will do serve any existing file, everything else is passed to the CI installation, it also takes out the index.php of the URL :

<IfModule mod_rewrite.c>

    
RewriteEngine On
    
    
# On some servers the base need to be set
    
RewriteBase /

    
# if file / folder does not exist
    
RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
%{REQUEST_FILENAME} !-d

    
# Take out index.php
    
RewriteRule ^(.*)$ index.php/$1 [L]
    
</IfModule
 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

 
Posted: 12 May 2009 08:36 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-05-10
4 posts

I applied that but it’s not working.For example my url is http://test.com/contactus when i browse it should redirect http://test.com/contactus.html.Please guide me or help me to write rewrite rule.

 
Posted: 12 May 2009 10:46 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2006-08-26
660 posts

In my example You need to call http://test.com/contactus.html and it will show contactus.html when the file exists, otherwise it will call the CI installation.

To use addresses ending with .html (http://test.com/whatsoever.html) as address for CI, You need to set in the config

// not sure about the point, though
$config['url_suffix'".html"

see User Guide - URL’s

I do not know how to add a html suffix in a .htaccess file.

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

 
Posted: 30 October 2012 12:40 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-10-22
5 posts

thanks for question, i have solution now smile

nuryanto