1
我是yii2的新手,我按照說明安裝yii2 by composer,但卡在ubuntu服務器的url rewrite配置中。yii2 url rewrite config
我的Apache2配置文件如下:如下
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我可以正常訪問該網站
<?php
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false
],
],
];
我的虛擬主機:
Alias /math2 /usr/share/math2/frontend/web
Alias /admin /usr/share/math2/backend/web
<Directory "/usr/local/math2/frontend/web">
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
RewriteBase /math2
#RewriteRule . index.php
RewriteRule ^.*$ index.php [L]
</Directory>
<Directory "/usr/local/math2/backend/web">
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteBase /admin
RewriteRule . index.php
</Directory>
和警予的配置文件如下通過http://localhost/math2/index.php/site/about
但它是假設被訪問 http://localhost/math2/site/about 我現在得到一個404錯誤。
它是Apache的404或404的Yii錯誤?這個非常重要。如果它是apache 404,比它的apache配置錯誤。 – 2015-02-09 11:09:54
它是apache 404 – 2015-02-09 11:11:17
好像你需要配置apache虛擬主機才能工作。見http://www.yiiframework.com/forum/index.php/topic/47615-yii-20-basci-app--miss-the-htaccess-file/ – apoq 2015-02-09 12:39:21