views:

42

answers:

1

My codeigniter application directory structure is like

--application
--htdocs
   --index.php
   --.htaccess
   --folder
       --file1.xml

Now I have a url http://mysite.com/folder. This is showing the files list in the folder directory. What I want here is to rewrite this url to a controller on my site say 'html.php'.

Note: I do not want to redirect. I want the url to be same but instead of showing folder contents, I want to pass the control to a controller. What .htaccess rule should I write?

+2  A: 

have you looked at url routing?

ie

$route['folder'] = "html"; //html is your controller

www.yoursite.com/folder

will "redirect" to yoursite.com/html but won't change the URL.

no need to mess with htaccess

edit:

RewriteEngine On
RewriteBase /

#ignored folders/files
RewriteCond $1 !^(index\.php|robots\.txt|img/|css/|js/)

RewriteRule ^(.*)$ index.php?/$1 [L] 

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

obtained from - http://codeigniter.com/forums/viewthread/153228/

perhaps this is what you are after?

Ross
see edited response. might help
Ross
I would highly consider what Ross is saying, if anything you would want to clean the URL and make it easier for people to remember. People wont remember `http://example.com/index.php/doctors/doctorname` they will instead remember `http://example.com/doctor/swanson`
WarmWaffles