[Symfony] Enabling mod_rewrite to Fix Apache Standard 404 Not Found Display

Tadashi Shigeoka ·  Tue, November 8, 2011

In Symfony 1.4, I encountered a situation where Apache’s standard 404 Not Found was displayed when switching to the prod environment.

I resolved this by enabling Apache’s mod_rewrite, so here are the steps for reference.

There seem to be other solutions for when switching from dev to prod environment doesn’t work, so if you’re stuck, read the article below.

dev環境からprod環境に変えると動かなくなる時の対処方法 « symfonyで開発日記

In this case, the symptoms were:

http://example.com/index.php/login
http://example.com/frontend_dev.php/login

These URLs were accessible, but

http://example.com/login

This URL was not accessible.  

Check if Apache's mod_rewrite is Enabled

First, to check if mod_rewrite is enabled, add the -l option to apachectl to check the list of compiled modules.

# /usr/local/apache2/bin/apachectl -l
Compiled in modules:

  mod_rewrite.c

If mod_rewrite.c is present, you’re good.

If not, add the —enable-rewrite option to config.nice and recompile and reinstall.  

Enable mod_rewrite and Reinstall

# /usr/local/src/httpd-2.2.21/config.nice --enable-rewrite
# make
# make install

By the way, running make install won’t overwrite existing documents, log files, or configuration files.

・参考:コンパイルとインストール - Apache HTTP サーバ

After installation, check again with apachectl -l to confirm that mod_rewrite.c is present.

That’s all from the Gemba.