Welcome Guest, Not a member yet? Register   Sign In
Should there be an htaccess file?
#1

[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!
#2

[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>
#3

[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?
#4

[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
#5

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

[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 ^^




Theme © iAndrew 2016 - Forum software by © MyBB