问题描述
我工作的一个Yii2项目,并设置它在WAMP本地主机。我WAMP我已成立了一个别名:
I am working on a Yii2 Project and have set it up on Wamp Localhost. My Wamp I have set up an alias:
Alias /project "c:/Users/Shaun/Desktop/projects/project/web/"
<Directory "c:/Users/Shaun/Desktop/projects/project/web/">
AllowOverride all
</Directory>
在一个基本的应用程序,我已经把htaccess的文件到web目录(它正在指向)
In a basic app I have placed the htaccess file into the web directory (where it is currently pointing to)
项目/网络/的.htaccess
项目/网络/的index.php
project/web/index.php
项目/网络/索引test.php的
project/web/index-test.php
mod_rewrite的肯定是启用我已检查。我可以浏览到我的根没有问题:
mod_rewrite is definitely enabled I have checked. I can navigate to my root without a problem:
这是我的htaccess的文件作为证明的Yii2文档。
This is my htaccess file as demonstrated on Yii2 docs.
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
http://localhost/project/
当我浏览到以上网址我打我的SiteController指数动作的罚款。但是,当我试着去,例如:
When I navigate to url above I hit my SiteController Index action fine. But when I try to go to for example:
http://localhost/project/site/index
它指出:
所请求的网址/Users/Shaun/Desktop/projects/project/web/index.php在此服务器上找到。
但它肯定是存在的?如果你看到我的web.php配置的一个组成部分我已经启用:
But it is definitely there?! If you see my web.php configuration as a component I have enabled:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
]
还没有找到它。但是,如果我这样做是显示了路线罚款:
Still can't find it. But if I do this it shows the routes fine:
http://localhost/project/index.php/site/index
这么折腾,因为我不想要这个。这是怎么回事吗?
So frustrating as I don't want this. What's the deal here?
谢谢
推荐答案
您必须改变三个文件。
基本>的.htaccess
基本>网络>的.htaccess
基本>配置> web.php
You have to change three files.
basic > .htaccess
basic > web > .htaccess
basic > config > web.php
使用在以下网址提供的code。
Use the code given in the below url.
HTTP://www.$c$cmatrics.com / htaccess的功能于yii2-基本应用内/ A>
这会帮助你。
这篇关于.htaccess中的Yii 2配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!