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

I am using Apache 2.2.22 on Ubuntu 12.04 with PHP 5.3.10. The real domain name has been obfuscated to example.com for this question.

I am attempting to set AllowOverride to None. I currently have an .htaccess file in my DocumentRoot. This is what it looks like:

<IfModule mod_rewrite.c>

    # Make sure directory listing is disabled
    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # Send request via index.php (again, not if its a real file or folder)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # deal with php5-cgi first
    <IfModule mod_fcgid.c>
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

    <IfModule !mod_fcgid.c>

        # for normal Apache installations
        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>

        # for Apache FGCI installations
        <IfModule !mod_php5.c>
            RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
        </IfModule>

    </IfModule>

</IfModule>

I ran phpinfo() to determine that my Server API is Apache 2.0 Handler. This makes me think that the rewrite rule that I need is RewriteRule ^(.*)$ index.php/$1 [L]. Is that correct?

I tried to move this rewrite rule into my sites-available/example.com configuration file, but whenever I set AllowOverride to None, I end up with a 500 error.

This is what my example.com configuration file looked like before:

<VirtualHost *:80>
        ServerName example.com
        ServerAdmin webmaster@localhost

        DocumentRoot /httpd/www/example.com/public
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /httpd/www/example.com/public>
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/example.com-error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>

The above configuration works fine. I attempted to merge the contents of my .htaccess file into my sites-available/example.com file. The results look like this:

<VirtualHost *:80>
        ServerName example.com
        ServerAdmin webmaster@localhost

        DocumentRoot /httpd/www/example.com/public
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /httpd/www/example.com/public>
                Options +FollowSymLinks -Indexes
                RewriteEngine on
                RewriteRule ^(.*)$ index.php/$1 [L]
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/example.com-error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>

Oh wow. What a n00b. Do you see what I did wrong? I sure do.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Maybe if I put the RewriteCond and RewriteRule directives in the correct order (RewriteCond comes BEFORE RewriteRule)...yeah, that helps.

share|improve this answer

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.