Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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 Hopkins Sep 6 '11 at 2: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 6 '11 at 2: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 Hopkins Sep 6 '11 at 4:35
    
Glad to hear that you've got it nearly better now. But how in the world is httpd.conf empty? –  U4iK_HaZe Sep 6 '11 at 4:41
    
It's all in apache2.conf, and the VirtualHosts are in sites-available. –  Michael Hopkins Sep 6 '11 at 4:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.