PHP Codeigniter - Apache virtual host setup trouble

Tilman Koester picture Tilman Koester · Nov 5, 2010 · Viewed 20.9k times · Source

This has been doing my head in. Hope you guys can help. I can't find out where the error lies.

httpd-vhosts.conf

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
    DocumentRoot /opt/lampp/htdocs
    ServerName localhost
</VirtualHost>

<VirtualHost 127.0.0.1>
    DocumentRoot /home/tilman/Sites/mysite/www
    ServerName mysite.lo
</VirtualHost>

/etc/hosts

127.0.0.1   localhost
127.0.0.1   mysite.lo

config.php

$config['base_url'] = "http://mysite.lo";
$config['index_page'] = "";

www/.htaccess

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

Now http://mysite.lo shows me the default controller. http://mysite.lo/index.php as well. So does http://mysite.lo/index.php/welcome.

But http://mysite.lo/welcome doesn't.

http://localhost/mysite/www/welcome works as expected.


edit: I want to move system and application out of the web root. So my file structure looks like this:

application/
system/
www/
 '- index.php

In index.php I changed the paths to system and application folder, of course.

Answer

wizardfrag picture wizardfrag · Nov 5, 2010

Sounds like you're having rewritemod/htaccess issues rather than VirtualHost issues. Have you made sure that you've got a block such as

<VirtualHost *:80>
  ServerName mysite.lo
  <Directory /home/tilman/Sites/mysite>
    AllowOverride All
  </Directory>
</VirtualHost>

somewhere within your config files? The fact that /index.php and /index.php/welcome work, tell me that it's the rewrite mod that's not functioning...