Yii 如何获得干净漂亮的 URL [英] Yii how to get clean and pretty URL

查看:17
本文介绍了Yii 如何获得干净漂亮的 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Yii 框架的新手.我在配置文件中取消了对 url 管理器的注释,并得到了这样的 url 方案:

I am newbie to Yii framework. I have uncommented the url manager in the config file and got a url scheme like this:

http://localhost/mysite/index.php/displayAll

我不想要 url 中的 index.php.所以我想要一个像这样的网址

I don't want the index.php in the url. So I want a url some thing like this

http://localhost/mysite/displayAll

要做到这一点,我该怎么做.我确实使用了 url 管理器和一些 htaccess,但没有任何进展.

To accomplish this, what should I do. I did play with the url manager and some htaccess, but nothing gone well.

请帮忙

推荐答案

尝试:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?mysite/(.*)$ /mysite/index.php/$1 [L]

这篇关于Yii 如何获得干净漂亮的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆