Solution for Forced URL Suffix, and enabled query strings without disrupting the Segment URL's |
[eluser]mynameiszanders[/eluser]
After my last post, where I wanted to force the URL Suffix, I made two extensions: one for the URI Class and another for the Input and Security Class. These two combined allow for the forcing of the URL Suffix, and allow query strings to be present without them affecting the way CodeIgniter compiles the URL from segments. Thanks to Hermawan Haryanto, for replying to my post (in less than 10 minutes) and leading me in the right direction! I consider myself quite advanced in PHP, but this is only my second post on this forum, and this work/code/development attempt is the first piece of work I have ever submitted anywhere, not just CodeIgniter. (Hardly anyone even knows what XML is let alone PHP in my lovely town of Tewkesbury, famous for its Abbey, Annual Medieval Fayre and the GREAT FLOOD 2007!) I would greatly appreciate ANY and ALL criticism to my work, whats wrong with it, what could be improved, performance and security-wise. Thankyou! This can be downloaded as a zip file, containing both files, and two HTML Files for documentation (I failed GCSE English to don't expect for it to be perfect ). Please rename the file as '.zip' as I'm not allowed to upload anything but images... naughty me EDIT: Funnily enough I do believe the zip file thing doesn't work... follow this link instead: http://zafr.googlecode.com/files/codeign...suffix.zip MY_URI Code: <?php if(!defined('BASEPATH')) {header('HTTP/1.1 404 Not Found'); exit;} MY_Input Code: <?php if(!defined('BASEPATH')) {header('HTTP/1.1 404 Not Found'); exit;} After this I have a new found respect for the CodeIgniter Dev Team, not because of their Framework, but for their seemingly perfect ability to write brilliant documentation! I never expected it to be so hard! (Obviously these aren't that hard but I'm currently working on a Template and Document Assets Class, and the documentation is the thing that makes me want to smash my computer in!)
[eluser]Kromack[/eluser]
Hello and thanks for your contribution. It looks very cool but I'm curious, what is the aim of gorcing the URL suffix ? Is it in order to seo ?
[eluser]mynameiszanders[/eluser]
Yes SEO is a very good use for it, but no, initially I did it just because being able to access it without the suffix annoyed me, no other reason zanders
[eluser]James V[/eluser]
For users interested in forcing a suffix, make a small change in the .htaccess file. Example, to get www.mysite.com/blog.html I changed the following .htaccess line Code: RewriteRule ^(.*)$ index.php?/$1 [L] Code: RewriteRule ^(.*)\.html$ index.php?/$1 [L] |
Welcome Guest, Not a member yet? Register Sign In |