CodeIgniter Forums
.htaccess Ignore Existing Folders - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: .htaccess Ignore Existing Folders (/showthread.php?tid=29851)



.htaccess Ignore Existing Folders - El Forum - 04-23-2010

[eluser]BradEstey[/eluser]
My .htaccess file is pretty simple.

Code:
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php|robots\.txt|img/|css/|js/)
RewriteRule ^(.*)$ index.php?/$1 [L]

Basically it just sends everyone to the index.php file, except calls inside the img/, css/, or js/ directories or the robot.txt. This works out pretty well because I can still have a page called site.com/img if I want (though I obviously wouldn't.. but by putting in the / after the directory name it keeps it from ignoring pages like site.com/imgggg or whatever else may start with the letters 'img'.)

My problem is, lets say i create a folder called 'products' in my public directory and also have a page called site.com/products. for some reason site.com/products/ works fine and loads the controller, but without the trailing slash it forces you to go to site.com/products/?/products

This isn't a debilitating issue or anything, but I just thought it was strange. Is something in my .htaccess triggering this or is it something in the CodeIgniter core?


.htaccess Ignore Existing Folders - El Forum - 04-24-2010

[eluser]frist44[/eluser]
add this to htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

it'll only redirect if it doesn't find the request as a file or directory on your server