首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yii2人类可理解的URL

Yii2人类可理解的URL
EN

Stack Overflow用户
提问于 2017-10-02 14:04:06
回答 1查看 58关注 0票数 0

早上好!)

urls不能正常工作。我有一个干净的yii2模板。我在config/web.php这个代码块中取消了注释:

代码语言:javascript
复制
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],

在组件的请求中添加了'baseUrl'=> '‘,

在根文件夹.htaccess中添加:

代码语言:javascript
复制
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

在添加的web文件夹中:

代码语言:javascript
复制
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

删除样式。当我删除'baseUrl'=> '‘时,它们被返回。链接/site/about主页上的销售线索,而不是指向web/site/about。在源代码中插入了css。

代码语言:javascript
复制
<link href="/assets/7fb759e5/css/bootstrap.css" rel="stylesheet">
<link href="/css/site.css" rel="stylesheet"></head>

谢谢!日安))

EN

回答 1

Stack Overflow用户

发布于 2017-10-30 15:05:31

让我猜猜-你的漂亮卷轴坏了。

  • 确保您的apache / web服务器从根文件夹使用apache .htaccess正常工作,并将apache DocumentRoot设置为/任意/path/ is /there/ to文件夹/web server

顺便说一句。不应直接设置yii\helpers\BaseUrl属性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46520241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档