漂亮的网址 - Yii2无法正常工作

时间:2017-06-07 07:28:46

标签: php yii yii2 httpd.conf yii-url-manager

使用yii2开发Web服务。如果启用了漂亮的URL,则结果始终返回404未找到。我怀疑htaccess或httpd.conf无效。

预期路线: http://localhost:63342/myproject/admin/api/totalviews

如果漂亮的网址被禁用, http://localhost:63342/myproject/admin/index.php?r=api/totalviews正在发挥作用。

这是web.php。

'id' => 'basic',
'basePath' => dirname(__DIR__),
'homeUrl' => 'http://localhost:63342/myproject/admin/', 
'bootstrap' => ['log'],
'defaultRoute' => 'login/index',
'components' => [
    'twiliosms' => [
        'class' => 'app\components\TwilioSms',
    ],
    'request' => [
        'cookieValidationKey' => 'abc123',
        'parsers' => [
            'application/json' => 'yii\web\JsonParser',
        ]
    ],
    'urlManager' =>
        [
            'class' => 'yii\web\UrlManager',
            'showScriptName' => false,
            'enablePrettyUrl' => true,
            'rules' => [
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                '<view:(about)>' => 'login/page',
                '<action:(index)>' => 'login/<action>',
                '<action:(forgotpassword)>' => 'login/forgotpassword<action>',
                '<alias:dashboard|forgotpassword>' => 'login/<alias>',
            ],
        ]

这是根目录中的.htaccess文件。

`<IfModule mod_autoindex.c>
  Options -Indexes
</IfModule>

<IfModule mod_rewrite.c>
  RewriteCond %{SCRIPT_FILENAME} -d
  RewriteCond %{SCRIPT_FILENAME} -f
  RewriteRule "(^|/)\." - [F]
</IfModule>

<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
  Order allow,deny
  Deny from all
  Satisfy All
</FilesMatch>

<IfModule php5_module>
  php_value session.cookie_httponly true
</IfModule>

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php`

这是管理员文件夹中的admin。\ 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

我正在使用wamp服务器,这是httpd-vhost.conf文件。

<VirtualHost *:8080>
ServerName localhost
DocumentRoot c:/wamp64/www 
<Directory  "c:/wamp64/www">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
</Directory>

有什么想法吗?

0 个答案:

没有答案
相关问题