CodeIgniter Forums
Adding a .html in the suffix does not do anything - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Adding a .html in the suffix does not do anything (/showthread.php?tid=15496)



Adding a .html in the suffix does not do anything - El Forum - 02-06-2009

[eluser]gh0st[/eluser]
Hi there.

I'm wanting to add a .html suffix in the URL.

In the config, you can add a suffix, such as '.html', or whatever you like.

However, if you go to;

http://ci.localhost/helloworld

And press enter, nothing is appended to the URL...

Why is this, and how do you fix it?


Adding a .html in the suffix does not do anything - El Forum - 02-06-2009

[eluser]Jelmer[/eluser]
Links generated by CI functions like anchor() should include it. Adding the suffix doesn't make CI auto add it to your URLs while accessing them, only through functions.

In my case the requests are accepted only if the include the .html suffix because of my .htaccess:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ /index.php?/$1

And all others throw an error with CI because of these instructions:
Code:
ErrorDocument 404 /error/404.html
ErrorDocument 403 /error/403.html
ErrorDocument 500 /error/500.html
(which are routed by my application to the corresponding error functions in my error controller)


Adding a .html in the suffix does not do anything - El Forum - 02-06-2009

[eluser]gh0st[/eluser]
Oh Okay. I'll look into this more.

Ideally I'd love to have it automatically appending, regardless of whether you put the extension or not.


Adding a .html in the suffix does not do anything - El Forum - 10-19-2010

[eluser]John_Betong[/eluser]
[quote author="Jelmer" date="1233949446"]

Links generated by CI functions like anchor() should include it. Adding the suffix doesn't make CI auto add it to your URLs while accessing them, only through functions.

In my case the requests are accepted only if the include the .html suffix because of my .htaccess:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ /index.php?/$1
[/quote]

I am in the process of trying to change an existing site using the config.php URL suffix ".html"

Most of the site is now working but a new hurdle has arisen because of REMOTE URLs without any extension. (The old site had no index.php, etc)

I have tried without success in re-routing these URLs but they fall over in the .htaccess file and never even reach the hidden index.php.

I use the following .htaccess code:

Code:
RewriteRule ^(.*).html$ /index.php?/$1

[/code]

I have unsuccessfully searched for a .htaccess solution and would be gratefult if anyone can supply the .htaccess code to append .html to the offending REMOTE URLs