Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just set up Apache and PHP on a server running CentOS by using something along the lines of yum install httpd and yum install php.

I've created the following file in /etc/httpd/conf.d/vhosts.conf:

NameVirtualHost *:80

<VirtualHost *:80>
     DocumentRoot /var/www/
     ErrorLog /var/www/
     CustomLog /var/www/ combined

Not that it isn't actually, it's the actual domain that I'm using.

Then, in /var/www/ I have the following:

RewriteEngine On
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

The problem is I'm getting 404 not found errors when accessing a URL like The requests don't seem to be going through the index.php script which the .htaccess file tells them to.

I've tried setting RewriteBase to /var/www/ but still no luck.

I have the same thing set up on localhost for development and it works perfectly. Can anyone spot what might be going wrong here?

share|improve this question
1) Why not put the rewrite stuff in the apache config as well? 2) – andol Feb 23 '13 at 21:23

Check whether there is a directive in your Apache config and there is AllowOverride. If should be set on All. If it is not there, add it to make sure the .htaccess file is being read.


Mohammad Ali Sharpasand

share|improve this answer

Your Answer


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.