为.htaccessconfiguration新服务器

我有一个新的LAMP CENTOS 5服务器,我正在设置,并试图从我有另一个Web服务器复制configuration。 我坚持我认为是一个mod_rewrite问题。 如果我去http://old-server.com/any_page_name.php它正确路由通过index.php中的一些处理代码,并显示我一个优雅的“页面无法显示”消息。

但是,如果我去http://new-server.com/any_page_name.php我得到一个丑陋的Apache 404 Not Found错误消息。

我查看了两个httpd.conf文件,它们都只有一个对mod_rewrite的引用。 LoadModule rewrite_module modules / mod_rewrite.so所以看起来应该没问题。

在httpd.conf的底部,我有这样的代码:

<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html ServerName new-server.com ErrorLog logs/new-server.com-error_log CustomLog logs/new-server.com-access_log common </VirtualHost> 

然后在/ var / www / html的根目录中,我有完全相同的.htaccess文件,如下所示:

 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 </files> 

所以我不明白为什么页面加载在old-server.com工作正常,而new-server.com不路由通过index.php像我想要做的。

谢谢。

您可能需要将AllowOverride All选项设置为允许.htaccess文件。

在旁注:也许你应该考虑将服务器逻辑移动到服务器configuration。