thinkphp在apache、nginx和iis下的URL重写

apache

xml 复制代码
<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  # RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
  # 下面是正确的
  RewriteRule ^(.)$ index.php?/$1 [QSA,PT,L]
</IfModule>

iis

xml 复制代码
<rewrite>
 <rules>
 <rule name="OrgPage" stopProcessing="true">
 <match url="^(.*)$" />
 <conditions logicalGrouping="MatchAll">
 <add input="{HTTP_HOST}" pattern="^(.*)$" />
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php/{R:1}" />
 </rule>
 </rules>
 </rewrite>

nginx

c 复制代码
#user  nobody;
worker_processes  1;

# 打开log
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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
    access_log  logs/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
	server {
		listen 80;
		server_name localhost;

		root D:/work/public;

		index index.php;

		location / {
			try_files $uri $uri/ /index.php$uri$is_args$query_string;
		}

		location ~..php($|/) {
			fastcgi_split_path_info ^(.+.php)(.)$;
			fastcgi_pass 127.0.0.1:9000;
			# linux 
			# fastcgi_pass unix:/var/tmp/php-fpm/php-fpm.sock;
			fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
			fastcgi_param PATH_INFO $fastcgi_path_info; # TP要这玩意
			include fastcgi_params;
		}
	}
}

https://www.kancloud.cn/manual/thinkphp6_0/1037488

相关推荐
it技术分享just_free5 分钟前
基于 K8S kubernetes 搭建 安装 EFK日志收集平台
运维·docker·云原生·容器·kubernetes·k8s
dream_ready36 分钟前
linux安装nginx+前端部署vue项目(实际测试react项目也可以)
前端·javascript·vue.js·nginx·react·html5
2407-2 shw38 分钟前
weblogic CVE-2018-2894 靶场攻略
java·运维·服务器·安全·weblogic
奇点 ♡1 小时前
【线程】线程的控制
linux·运维·c语言·开发语言·c++·visual studio code
向往风的男子1 小时前
【devops】devops-ansible之介绍和基础使用
运维·ansible·devops
xiaojiesec2 小时前
第159天:安全开发-Python-协议库爆破&FTP&SSH&Redis&SMTP&MYSQL等
运维·安全·ssh
技术不支持2 小时前
WSL2+Ubuntu 22.04搭建Qt开发环境+中文输入法
linux·运维·服务器·qt·ubuntu
木人舟2 小时前
以root用户登陆ubuntu的桌面环境
linux·运维·ubuntu
几度热忱2 小时前
【Ubuntu】Ubuntu双网卡配置 实现内外网互不影响同时可用
linux·运维·ubuntu