Question

Why is mod_rewrite only working for one virtual host but not other?

I have two applications running on the same droplet (Ubuntu 14.04, Apache 2, PHP 5.5.9) each one as a different virtual host.

On application is using Codeigniter 2.2.6, the other one Codeigniter 3.0.6.

Both applications have very similar Apache .conf, .htacces files, where the only difference is the domain name.

Also regarding Codeginiter, both have very similar config files with $config[‘index_page’] set to empty.

My problem is that mod_rewrite is only working for the oldest application running Codeingniter 2, and not for the new one in Codeigniter 3.

Locally mod_rewrite works fine on both apps under MAMP.

Any ideas of what could be wrong?

.htaccess

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

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

.conf

<VirtualHost *:80>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Never mind. I figured out myself.

It turns out that because I was using HTTPS y was looking in the wrong place.

My error was on <VirtualHost *:443> part of the config file.

Thanks any way

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.