4

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.

Tilman Koester
  • 1,739
  • 2
  • 11
  • 25

2 Answers2

9

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...

wizardfrag
  • 106
  • 3
  • Man, so silly, I simply forgot to add that directive. Good eye. Thanks. – Tilman Koester Nov 05 '10 at 09:48
  • I ended up here with a problem related to loading static assets (css, js...) for a CakePHP site on index.php and also with a CodeIgniter site that was loading the index.php perfectly but then all the internal routing was giving 404 errors. I added the "AllowOverride All" for the directory configuration and that did the trick for both issues. – a4bike Oct 13 '16 at 18:38
0

In your virtual host, do you not need this?

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

I'm not sure you needed the www portion.

Martin Bean
  • 38,379
  • 25
  • 128
  • 201