0

I have a CodeIgniter installation in a VirtualHost on Apache2 on Ubunto Natty set up as follows:

/application
/system
...
/www/index.php

Here is my .htaccess which resides in /:

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /

        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /www/index.php?/$1 [L]

        RewriteCond %{REQUEST_URI} ^application.*
        RewriteRule ^(.*)$ /www/index.php?/$1 [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /www/index.php?/$1 [L]
</IfModule>

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

What I see, when I navigate to the site, is the attached picture: apache directory listing with no www folder in sight

Here's what I see when I run ls -al in /:

total 44
drwxr-xr-x  8 admin admin 4096 2011-09-06 00:35 .
drwxr-xr-x  3 admin admin 4096 2011-09-04 06:36 ..
drwxr-xr-x 12 admin admin 4096 2011-09-04 06:29 application
-rw-r--r--  1 admin admin   94 2011-09-05 18:53 .hg_archival.txt
-rw-r--r--  1 admin admin  431 2011-09-06 00:35 .htaccess
-rw-r--r--  1 admin admin 2496 2011-09-05 18:53 license.txt
drwxr-xr-x  2 admin admin 4096 2011-09-06 00:32 logs
drwxr-xr-x 10 admin admin 4096 2011-09-04 06:29 system
drwxr-xr-x  2 admin admin 4096 2011-09-06 00:30 test
drwxr-xr-x 11 admin admin 4096 2011-09-04 06:29 user_guide
drwxr-xr-x  5 admin admin 4096 2011-09-04 06:29 www

What do I need to change so that my www folder appears, allowing my ReWriteRule to work, or is that even the problem?

P.S. Should mention that my files arrive in this folder via a post-receive Git hook after being pushed to a repository elsewhere on the server. I don't think it matters because every file seems to be arriving, but I'll mention it.

Michael
  • 125
  • 5

1 Answers1

0

You don't want to set your INDEX page to a 404 page, otherwise it will not load. Simple. Try this:

If you want to have a www-redirect, make a v-host with just your external IP.

#vHosts Config:

NameVirtualHost *:80

<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^\.]+\.[^\.]+)$
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
<Directory "C:/xampp/htroot">
    AllowOverride All
    Options Indexes FollowSymLinks Includes ExecCGI
    Order allow,deny
    Allow from all
</Directory>

otherwise put this in a .htaccess file in the root directory of the site

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^\.]+\.[^\.]+)$
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

and MAKE SURE you allow indexes and the goody-two-shoes options directives. That should fix you.

EDIT: You can pretty much remove the "ifmodule" tags. Try it that way too. At least explain what your problem is, it's a little bland.

U4iK_HaZe
  • 633
  • 5
  • 13
  • It's not that I want a www redirect, it's that I have a folder /www that doesn't even exist according to Apache, and my index.php referred to in the .htaccess is inside there. Unless I misunderstand. – Michael Sep 06 '11 at 02:06
  • Ah okay. Please post the httpd.conf file, and we can take a look. You likely changed the apache root directory to somewhere else. ALSO: post the contents of "error.log" in it. Specifically what appears for the IP 96/245/217/161 please. I want to see what apache is doing with my request. – U4iK_HaZe Sep 06 '11 at 02:27
  • My httpd.conf file is empty. In apache2.conf, I hadn't set serverroot yet, so I uncommented the default line -- it is /etc/apache2. I also realized I hadn't enabled mod_rewrite so I enabled that. As soon as I did that, the /www directory appeared! Everything is still not configured correctly, but I am further along now. – Michael Sep 06 '11 at 04:35
  • Glad to hear that you've got it nearly better now. But how in the world is httpd.conf empty? – U4iK_HaZe Sep 06 '11 at 04:41
  • It's all in apache2.conf, and the VirtualHosts are in sites-available. – Michael Sep 06 '11 at 04:50
  • Okay, gotcha. Well good luck to you. – U4iK_HaZe Sep 06 '11 at 04:53
  • Thanks. You definitely got me going in the right directions. – Michael Sep 06 '11 at 04:59