CodeIgniter Forums
Rewriting with and without url_suffix - 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: Rewriting with and without url_suffix (/showthread.php?tid=12790)



Rewriting with and without url_suffix - El Forum - 10-31-2008

[eluser]Isuka[/eluser]
Hello,

In my config.php file I enable the url_suffix option with .html so all my pages are .htmled.
In my .htaccess I removed the index.php like that
Code:
RewriteRule ^(.*).html$ index.php?/$1 [L]

If I go to mysite.com/about.html everything work fine, but if I go to mysite.com/about, I got a 404 Not Found, the default 404 page of Apache.

So I try to add another rule in my .htaccess, without the suffix
Code:
RewriteRule ^(.*)$ index.php?/$1
RewriteRule ^(.*).html$ index.php?/$1 [L]
Now if I go to mysite.com/about.html and mysite.com/about, both url gave me a 404 Not Found but the CI 404 page this time.

Maybe an .htaccess expert could tell me how can I do ?

Thanx Smile


Rewriting with and without url_suffix - El Forum - 10-31-2008

[eluser]Jelmer[/eluser]
I'm not entirely sure but the first rule is obiously going to match to .html pages as well as to non-html pages and send them in full to the controler. And it might go wrong if CI is not expecting .html suffixed urls?


Rewriting with and without url_suffix - El Forum - 10-31-2008

[eluser]Isuka[/eluser]
The weird thing is if I only have
Code:
RewriteRule ^(.*)$ index.php?/$1
in the .htaccess I go a CI 404 page too.