搜索
首页php框架YIIyii2如何隐藏index.php

yii2如何隐藏index.php

Aug 17, 2020 am 09:02 AM
index.phpyii2

yii2隐藏index.php的方法:首先打开urlManager组件的配置;然后配置文件nginx.conf内容;接着将项目域名的配置整体放在vhost目录下;最后在入口文件的同级目录下放置“.htaccess”文件即可。

yii2如何隐藏index.php

推荐:《yii教程

yii2 url 重写 隐藏 index.php 方法

第一步  : 不管是  apache 还是  nginx ,想要隐藏 Index.php 文件,需要打开  urlManager  组件的配置,在进行后续的操作

企业微信截图_15976257968073.png

第二步 :

nginx   下 :

配置文件  nginx.conf 内容如下 :

user  centos;
worker_processes  4; 
error_log  
logs/error.log; 
pid        logs/nginx.pid; 
 
events {    
worker_connections  10240;
} 
 
http {    include       mime.types;    
default_type  application/octet-stream; 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                      
    '$status $body_bytes_sent "$http_referer" '                      
    '"$http_user_agent" "$http_x_forwarded_for"'; 
    log_format log_json '{ "@timestamp": "$time_local", '                        
    '"remote_addr": "$remote_addr", '                        
    '"referer": "$http_referer", '                        
    '"request": "$request", '                        
    '"status": $status, '                        
    '"bytes": $body_bytes_sent, '                        
    '"agent": "$http_user_agent", '                       
    '"x_forwarded": "$http_x_forwarded_for", '                        
    '"up_addr": "$upstream_addr",'                        
    '"up_host": "$upstream_http_host",'                        
    '"up_resp_time": "$upstream_response_time",'                        
    '"request_time": "$request_time"'                        
    ' }'; 
 
   access_log  logs/access.log; 
    sendfile        on;    #tcp_nopush     on; 
    #keepalive_timeout  0;    keepalive_timeout  200;        
    client_max_body_size 200M;    gzip  on; 
        include vhost/*.conf;
}

项目域名的配置整体是放在  vhost  这个目录下面,改目录下其中一个文件的内容

server {        listen  80;        
server_name     域名; 
        # 项目 index.php 地址        
        root /home/centos/www/youdai-api/bird/web; 
        access_log logs/youdaiApi.access.log log_json;        
        error_log logs/youdaiApi.error.log; 
        location / {                
        try_files $uri $uri/ /index.php?$args;                
        index   index.php;
        } 
        location ~ \.php$ {                
        fastcgi_pass 127.0.0.1:9000;                
        fastcgi_index index.php;                
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;                
        include fastcgi_params;
        } 
        location ~ /\.ht {                
        deny all;
        }
}

apche 下 : 伪静态配置
入口文件的同级目录下,放置   .htaccess 文件

企业微信截图_15976258044716.png

内容如下 :

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

以上是yii2如何隐藏index.php的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
YII开发的关键技能:构建强大的Web应用程序YII开发的关键技能:构建强大的Web应用程序May 14, 2025 am 12:03 AM

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

成为成功的YII开发人员需要哪些技能?成为成功的YII开发人员需要哪些技能?May 13, 2025 am 12:01 AM

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

YII开发人员:常见错误YII开发人员:常见错误May 12, 2025 am 12:04 AM

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

YII开发人员:欧洲最重用的技能YII开发人员:欧洲最重用的技能May 11, 2025 am 12:02 AM

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

Yii:社区仍然活跃吗?Yii:社区仍然活跃吗?May 10, 2025 am 12:03 AM

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

将Laravel项目迁移到YII是否容易?将Laravel项目迁移到YII是否容易?May 09, 2025 am 12:01 AM

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

YII开发人员的基本软技能:沟通与协作YII开发人员的基本软技能:沟通与协作May 08, 2025 am 12:11 AM

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

Laravel MVC:最佳好处是什么?Laravel MVC:最佳好处是什么?May 07, 2025 pm 03:53 PM

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

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

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

热门文章

热工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境