tp5에서 index.php를 제거하는 방법
index.php
tp5
tp5去除index.php的方法:1、使用“\think\Url::root('/');”;2、修改htaccess配置,代码如“ RewriteCond %{REQUEST_FILENAME}...”;3、修改nginx配置即可。
环境:win10 + php7.1 + nginx1.2 + ThinkPHP5 + Dell G3电脑
tp5怎么去除index.php?
TP5 去除url中 index.php 方法
在使用 ThinkPHP5 过程中,用 url 函数生成链接地址时,地址中产生了 index.php
例:我们要生成一个 /home/news/list.html 的地址,结果生成的地址是 /index.php/home/news/list.html
在手册中 URL 生成篇有介绍:
还可以写成:
\think\Url::root('/');
로그인 후 복사
其它配置:
.htaccess配置 (nginx 可忽略此文件)
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>
로그인 후 복사
nginx配置
server{ listen 80;#监听端口 server_name www.demo.com;#域名 index index.html index.htm; root D:/wnmp/demo/public; location / { index index.html index.htm index.php; #autoindex on; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ { expires 30d; # access_log off; } location ~ .*\.(js|css)?$ { expires max; log_not_found off; access_log off; } error_page 500 502 503 504 /50x.html; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #下面两句是给fastcgi权限,可以支持 ?s=/module/controller/action的url访问模式 fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #下面两句才能真正支持 index.php/index/index/index的pathinfo模式 fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
로그인 후 복사
推荐学习:《thinkphp教程》
위 내용은 tp5에서 index.php를 제거하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사
어 ass 신 크리드 그림자 : 조개 수수께끼 솔루션
3 몇 주 전
By DDD
Windows 11 KB5054979의 새로운 기능 및 업데이트 문제를 해결하는 방법
2 몇 주 전
By DDD
Atomfall에서 크레인 제어 키 카드를 찾을 수 있습니다
3 몇 주 전
By DDD
R.E.P.O. 저축 설명 (및 파일 저장)
1 몇 달 전
By 尊渡假赌尊渡假赌尊渡假赌
어 ass 신 크리드 섀도우 - 대장장이를 찾고 무기 및 갑옷 커스터마 화 잠금 해제 방법
4 몇 주 전
By DDD

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제
Gmail 이메일의 로그인 입구는 어디에 있나요?
7563
15


Cakephp 튜토리얼
1385
52


Steam의 계정 이름 형식은 무엇입니까?
84
11


Win11 활성화 키 영구
61
19


NYT 연결 힌트와 답변
28
99

