I have a new LAMP CENTOS 5 server I am setting up and trying to copy the configuration from another web server I have. I am stuck with what I think is a mod_rewrite problem. If I go to http://old-server.com/any_page_name.php it correctly routes through some handling code in index.php and shows me a graceful "Page Cannot Be Displayed" message.

But if I go to http://new-server.com/any_page_name.php I get an ugly Apache 404 Not Found error message.

I looked in both httpd.conf files and they both have only one reference to mod_rewrite. LoadModule rewrite_module modules/mod_rewrite.so So it seems like that should be fine.

At the bottom of httpd.conf I have the code:

<VirtualHost *:80>
  ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot /var/www/html
  ServerName new-server.com
  ErrorLog logs/new-server.com-error_log
  CustomLog logs/new-server.com-access_log common

Then in the root of /var/www/html I have the exact same .htaccess file that looks like this:

RewriteEngine on
Options +FollowSymlinks

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

ErrorDocument 404 /page-unavailable/

<files ~ "\.tpl$">
order deny,allow
allow from none
deny from all

So I don't see why the page load at old-server.com works fine while new-server.com doesn't route through index.php like I want it to do.



You might need to set the AllowOverride All option to allow .htaccess files.

On a sidenote: Maybe you should think about moving the server logic into the server config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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