Welcome Guest, Not a member yet? Register   Sign In
Codeigniter, xampp (windows), mod_rewrite issues.
#1

[eluser]LonestarGEEK[/eluser]
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

Code:
/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

Code:
<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

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

app_name/main/config/config.php
Code:
$config['base_url'] = "http://localhost/app_name/";
$config['index_page'] = "";

app_name/main/config/routes.php

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

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

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

The alias is:

Code:
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

[eluser]Daniel Moore[/eluser]
Try making the following change and see if that works for you.

Code:
<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

[eluser]LonestarGEEK[/eluser]
[quote author="Daniel Moore" date="1259917947"]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.
[/quote]

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:

Code:
http://localhost/winscore/welcome/

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

[eluser]morcegon[/eluser]
Thanks man, it's work!!
#5

[eluser]nhantam[/eluser]
“mod_rewrite.so” Thanks you very much




Theme © iAndrew 2016 - Forum software by © MyBB