CakePHP漂亮的URL不适用于生产服务器

时间:2012-08-15 03:28:16

标签: apache cakephp vhosts

我已经开发了一个CakePHP应用程序,我现在已将其部署到我的生产服务器,但是漂亮的URL不起作用。

以下是该网站的Apache vhost:

<VirtualHost *:80>
       ServerName site.com
    ServerAdmin support@site.com

    DocumentRoot /home/whitey/sites/site.com/htdocs/app/webroot/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/whitey/sites/site.com/htdocs/app/webroot/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /home/whitey/sites/site.com/logs/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /home/whitey/sites/site.com/logs/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

如您所见,文档根目录设置为我的应用程序中的webroot目录。在该目录中,有这个.htaccess文件:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

这整个设置与我运行XAMPP的本地机器完美配合,所以我不确定是什么问题。我唯一能想到的是由于我的vhost中的设置,重写规则没有生效。但是我还没有足够的Apache配置文件知识来知道如何修复它。

感谢。

1 个答案:

答案 0 :(得分:1)

没关系,我是个白痴。我昨晚在设置时忘了为Apache启用mod_rewrite模块。这是修复:

sudo a2enmod rewrite
sudo service apache2 restart
相关问题