CodeIgniter Forums
Should there be an htaccess file? - 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: Should there be an htaccess file? (/showthread.php?tid=55129)



Should there be an htaccess file? - El Forum - 10-11-2012

[eluser]Lpeek[/eluser]
Hey! I'm new to CI and just wondering if there should be an htaccess file? I cant get the routing to work by just following the tutorial, and it seems bizarre that there is no htaccess file by default? I didn't think url rewriting was possible without using mod_rewrite?

With routing set to:

Code:
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';

I can go to www.mysite.com and I get the correct page. but going to www.mysite.com/pages/view/home I just get a 404.

Am I supposed to create an htaccess file which it just doesn't tell you about in the user guide? (or maybe it does tell you and I just missed it?)

Cheers!


Should there be an htaccess file? - El Forum - 10-11-2012

[eluser]alexwenzel[/eluser]
Checkout your app with the following .htaccess

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /your-site-whatever/
  
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
  
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>



Should there be an htaccess file? - El Forum - 10-11-2012

[eluser]Lpeek[/eluser]
Thanks alex! I'll give it a go.

Is that supposed to be a file somewhere in the download that ive missed? or is it just general-knowledge htaccess that everyone manually creates when starting a new projects?


Should there be an htaccess file? - El Forum - 10-11-2012

[eluser]alexwenzel[/eluser]
Its not included in the downloads. Its just a file i use on every of my projects since month. Seems to work, heh Wink


Should there be an htaccess file? - El Forum - 10-11-2012

[eluser]Aken[/eluser]
The system/application rules aren't necessary anymore - those folders have their own .htaccess files that deny access.


Should there be an htaccess file? - El Forum - 10-12-2012

[eluser]alexwenzel[/eluser]
[quote author="Aken" date="1350013535"]The system/application rules aren't necessary anymore - those folders have their own .htaccess files that deny access.[/quote]

Good to know. I just started to use my .htaccess file a while ago and copied it from one project to another ^^