yii url隐藏.php后缀的方法:1、增加.htaccess文件;2、在config/web.php中的components数组中增加“'urlManager' => [...]”;3、修改apache即可。
本文操作环境:Windows7系统、yii2.0版、Dell G3电脑。
yii url 怎么隐藏.php后缀?
Yii 框架开启 URL 美化,隐藏 index.php [ 2.0 版本 ]
url美化:
目的:将 http://localtest/yii/web/index.php?r=hello/index
美化成:http://localtest/yii/web/hello/index
这里我是用的wampserver新建了一个localtest站点(详情可点击这里点击这里),并将yii的basic文件夹重新命名为yii。
对比上面的两个地址,其实就是把index.php?r=隐藏。
这里分两步:
1、增加.htaccess文件
在web根目录下增加.htaccess文件,内容为:
RewriteEngine On DirectoryIndex index.html index.php # 如果是一个目录或者文件,就访问目录或文件 RewriteCond %{REQUEST_FILENAME} !-d #如果文件存在,就直接访问文件,不进行下面的RewriteRule RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php
无法直接创建.htaccess,可以先创建一个txt文件,然后另存为…,保存为文件名为.htaccess,保存类型选择所有文件即可。
2、配置config/web.php 在config/web.php中的components数组中增加这一项:
'urlManager' => [ // //开启url美化 'enablePrettyUrl' => true, // //隐藏index.php 'showScriptName' => false, // //禁用严格匹配模式 'enableStrictParsing' => false, // //url后缀名称 // 'suffix'=>'.html', 'rules' => [ ], ],
这时,可以将URL中的index.php?r=删除,如果出现404报错,可以查看服务器的配置,我用的是phpstudy中集成的apache 需要检查一下配置
conf\httpd.conf中,开启 apache 的 mod_rewrite 模块
去掉 LoadModule rewrite_module modules/mod_rewrite.so 前的“#”符号;
然后修改 apache 的 AllowOverride
将 AllowOverride None 修改为 AllowOverride All;
由于我是在conf\extra\httpd-vhosts.conf中配置了站点,所以需要同步去httpd-vhosts.conf中将对应站的 AllowOverride None 修改为 AllowOverride All;
至此,我就可以用 http://localtest/yii/web/hello/index
来访问 http://localtest/yii/web/index.php?r=hello/index
推荐:《yii教程》
以上是yii url 怎么隐藏.php后缀的详细内容。更多信息请关注PHP中文网其他相关文章!

tobuildRobustWebapplicationswithyii,MasterTheSeskills:1)MvCarchitectureForstructuringApplications,2)ActivereCordForefifficdataBaseOperations,3)widgetsystemporreusableReusableSueuiComponents,4)验证和验证和验证,5)cachingforpermificatization cachingforpermifications

tobecomeAccessfulyiideDeveloder,Youneed:1)phpmastery,2)理解,3)yiiframework-worksprofience,4)databasemanagementskills,5)前端知识,6),6)apevelight expertise,7)测试和debugggingCapabientials,8)9)

theSostCommonErrorsinyIiframeWorkare“ Unknownproperty”,“无效configuration”,“ classNotfound”和“ valianationerrors” .1。“ Unknownerproperty” errorSoccurWhenAccessingNon-existentSistentProperties; SusePropertiesexi; Susepropertiesexi;

欧洲Yii开发者需具备的关键技能包括:1.Yii框架精通,2.PHP熟练度,3.数据库管理,4.前端技能,5.RESTfulAPI开发,6.版本控制系统,7.测试与调试,8.安全知识,9.敏捷方法论,10.软技能,11.本地化与国际化,12.持续学习,这些技能使开发者在欧洲市场中脱颖而出。

Yes,theYiicommunityisstillactiveandvibrant.1)TheofficialYiiforumremainsaresourcefordiscussionsandsupport.2)TheGitHubrepositoryshowsregularcommitsandpullrequests,indicatingongoingdevelopment.3)StackOverflowcontinuestohostYii-relatedquestionsandhigh-qu

crigatingalaravel projectToyiiishallingButachieffable withiefleflant.1)mapoutlaravel组件likeoutes,控制器和模型。2)Translatelaravel's sartisancancancommandeloequorentoottooyii的giiandeteverecordeba

软技能对Yii开发者至关重要,因为它们促进团队沟通和协作。1)有效沟通确保项目进展顺利,如通过清晰的API文档和定期会议。2)协作通过Yii的工具如Gii增强团队互动,提高开发效率。

laravel'smvCarchitectureOfferSenhancedCodeorganization,改善确定性,andarobustseParefofConcerns.1)ItkeepscodeOdeOrganized,makenavigationNavigationAnvigationAndTeamWorkeer.2)itcompartmentalizestHeaplication,简化了tompertalizestHeaplication,简化了tlubloublyingttrublyingtimpertinging和maintenance.3)itse.3)itse


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

Dreamweaver Mac版
视觉化网页开发工具

SublimeText3汉化版
中文版,非常好用

SublimeText3 Linux新版
SublimeText3 Linux最新版

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。