ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Codeigniter, xampp (windows), mod_rewrite issues.

December 03, 2009 7:03pm

Subscribe [3]
  • #1 / Dec 03, 2009 7:03pm

    LonestarGEEK

    2 posts

    I’m a noob to CodeIgniter and am trying to figure out the configuration for an app I’m building. Something is wrong with my setup.

    I’m running XAMPP on Windows and am using an alias directory to point to the applications directory. In other words: “http://localhost/app_name/ ” points to the root directory of the application. It all seems to work well until I do the .htaccess for mod_rewrite. Then every time I try to go to a controller I get pitched back to the xampp root.

    My config is:

    Directories

    /app_root
    /app_root/codeigniter // where code igniter is located.
    /app_root/main        // where the main app is located.  It' the applications 
                          // directory cut from code igniter and renamed.

    .htaccess

    <IfModule mod_rewrite.so>
    RewriteEngine On
    RewriteBase /app_name/
    RewriteCond %{REQUEST_URI} ^codeigniter.*
    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>

    index.php

    $system_folder = "@codeigniter";
    $application_folder = "main";

    app_name/main/config/config.php

    $config['base_url'] = "http://localhost/app_name/";
    $config['index_page'] = "";

    app_name/main/config/routes.php

    $route['default_controller'] = "home";

    I should also state that the app_name directory is an alias for a different drive than the apache root.

    Apache Root: c:\xampp\htdocs\
    App_name: d:\projects\app_name\development\

    The alias is:

    Alias /app_name "d:/projects/app name/development"
    <Directory "d:/projects/app name/development">
      Options Indexes FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>

    Thanks in advance for the help…

  • #2 / Dec 03, 2009 11:12pm

    anonymous65551

    222 posts

    Try making the following change and see if that works for you.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /app_name/index.php?/$1 [L,QSA]
    </IfModule>
    <IfModule !mod_rewrite.c>
    ErrorDocument 404 /app_name/index.php
    </IfModule>

    I noticed you used <IfModule mod_rewrite.so>, but then you used <IfModule !mod_rewrite.c>.  You should either be using mod_rewrite.so OR mod_rewrite.c, but they are not interchangeable.  If you’re using XAMPP on Windows, then it’s most likely using mod_rewrite.so.  You can determine this from the XAMPP\apache\conf\httpd.conf file.  Do a search in a text editor for mod_rewrite.so and for mod_rewrite.c.  The one you find is the one you should use.

    Also, try reading up on my tutorial.  It should help you create a working .htaccess file for CodeIgniter for almost any server configuration, so it will be helpful when you start uploading your project to the web.

    Tutorial:// Removing index.php from CodeIgniter with .htaccess

  • #3 / Dec 04, 2009 12:05am

    LonestarGEEK

    2 posts

    Try making the following change and see if that works for you.

    ...
    I noticed you used <IfModule mod_rewrite.so>, but then you used <IfModule !mod_rewrite.c>. 
    ...

    Also, try reading up on my tutorial.  It should help you create a working .htaccess file for CodeIgniter for almost any server configuration, so it will be helpful when you start uploading your project to the web.

    Daniel,

    I read your tutorial once, but I will try it again.  “mod_rewrite.so” is the correct one on my xampp install.  My development environment is local, but I have a staging environment that is for the customer to view.  So I comment out one or the other.  I had accidentally missed that.

    I’ve set the default controller to “home” and the website comes up correctly, but now I can’t get to:

    <a href="http://localhost/winscore/welcome/">http://localhost/winscore/welcome/</a>

    Which should be correct.  The URL is redirected to “http://localhost/winscore/welcome/” but the code that comes up is the default controller “home.php”.  I’ll reread your tutorial again and let you know if I’ve figured it out.

    Thanks for the help!

  • #4 / Apr 27, 2010 11:01am

    morcegon

    4 posts

    Thanks man, it’s work!!

  • #5 / Nov 22, 2010 10:49pm

    nhantam

    10 posts

    “mod_rewrite.so” Thanks you very much

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases