CodeIgniter Forums
[solved] can't get my path working... - 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: [solved] can't get my path working... (/showthread.php?tid=16659)



[solved] can't get my path working... - El Forum - 03-13-2009

[eluser]m_ologin[/eluser]
Hi there, I have tried doing a simple web page with a form but get a 404 error, probably because I haven't configured my app right. Can someone please help?

Here is my file structure:

Code:
+ci
  +application
  +public_html
    +css
    +flash
    +img
    +js
    index.html
  +system
  +user_guide
  .htaccess
  index.php
  license.txt

.htaccess:
Code:
<IfModule mod_rewrite.c>
  DirectoryIndex index.php
  RewriteEngine on
  RewriteBase /ci/
  RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

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

config.php:
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['base_url']   = "http://localhost/ci/";
$config['index_page'] = "";
(...)

index.php:
Code:
(...)
$system_folder = "system";
$application_folder = "application";
(...)

routes.php:
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "login";
$route['scaffolding_trigger'] = "";

login.php (in controller folder):
Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends Controller {
    function Login()
    {
        parent::Controller();
    }
    
    function index()
    {
        echo "ok";
    }
    
    function submit()
    {
        echo "submitting";
    }
}

Now, when I go to http://localhost/ci/, it displays "ok" correctly. Yet, when I go to http://localhost/ci/login/submit, I have a 404 error.
The page can only be found at http://localhost/ci/index.php/login/submit...

Please advise. Thanks!

[SOLVED] :
I changed my <DIRECTORY> section to this:
<Directory />
Options All
AllowOverride All
</Directory>
in my httpd.conf apache file. Not great for security but I'm just working local for now...

Thanks!


[solved] can't get my path working... - El Forum - 03-13-2009

[eluser]Vicente Russo[/eluser]
Hi,

Try this:

<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>


[solved] can't get my path working... - El Forum - 03-13-2009

[eluser]m_ologin[/eluser]
No.. It still doesn't work. I have simplified my example (check above); but I still haven't managed to take out the index.php...


[solved] can't get my path working... - El Forum - 03-13-2009

[eluser]brianw1975[/eluser]
IIRC AllowOverride All is the requirement for using mod_rewrite so just tweak your Options tag and you'll be fine.

something like:

Code:
Options -Indexes -FollowSymlinks +FollowSymLinkIfOwnerMatch

should keep all the baddies from getting access to junk outside the webroot - as long as *you* know what you are doing hehe