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

相关推荐
浅念-5 小时前
Linux 开发环境与工具链
linux·运维·服务器·数据结构·c++·经验分享
似水এ᭄往昔7 小时前
【Linux】gdb的使用
linux·运维·服务器
优雅的造轮狮7 小时前
WSL2 Docker Desktop配置优化及迁移D盘指南
运维·docker·容器
大师影视解说8 小时前
基于Web端的AI电影解说自动化生产工具实测:4步完成从文案到成片的全流程
运维·人工智能·自动化·影视解说·电影解说工具·网页版电影解说·ai电影解说
mizuhokaga8 小时前
Linux内网集群基于Docker 安装 Chat2DB
linux·运维·docker
科士威传动8 小时前
微型导轨从精密制造到智能集成的跨越
大数据·运维·科技·机器人·自动化·制造
biubiubiu07069 小时前
Vibe Coding
运维
学不完的10 小时前
ZrLog 高可用架构监控部署指南(Prometheus + Grafana)
linux·运维·架构·负载均衡·grafana·prometheus·ab测试
北京智和信通10 小时前
可视・可管・可靠:智和信通赋能清华某院构建新一代监控运维平台
运维·网络监控·网管软件·信创运维·高校网络运维·高校网管
Sean‘10 小时前
AKS 集群离线部署 kube-state-metrics 文档
运维·docker·容器