UserDir和mod_rewrite

时间:2013-09-24 10:02:52

标签: apache .htaccess mod-rewrite yii

我正在使用Yii Framework创建一个网站并尝试隐藏条目脚本。在我的本地(MAMP)服务器上一切正常,但是当我将它部署到我的Uni的Linux服务器上时,我遇到了问题。我想这与UserDir有关,但我不确定。

当我要求时:http://website/username/site/research 我明白了:

The requested URL /~home/username/public_html/index.php was not found on this server.

我的.htaccess看起来像这样:

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule ^.*$ index.php

我不知道从哪里开始调查这个问题。可能是UserDir吗?或者使用我的.htaccessmod_rewrite?或者配置Yii

1 个答案:

答案 0 :(得分:0)

首先,试试这个:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

接下来,麻烦可能是因为apache配置。选项“AllowOverride”应设置为“All”:

<VirtualHost *:80>
    ServerAdmin admin@localhost
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /home/sites/example.com/frontend/www

    DirectoryIndex index.php index.html
    <Directory /home/sites/example.com/frontend/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
                allow from all
    </Directory>
</VirtualHost>