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

相关推荐
云和数据.ChenGuang4 分钟前
自动化运维工程师之ansible启动rpcbind和nfs服务
运维·服务器·运维技术·数据库运维工程师·运维教程
yimengsama5 分钟前
VMWare虚拟机如何连接U盘
linux·运维·服务器·网络·windows·经验分享·远程工作
松涛和鸣9 分钟前
32、Linux线程编程
linux·运维·服务器·c语言·开发语言·windows
云和数据.ChenGuang11 分钟前
AB压力测试运维工程师技术教程
运维·压力测试·运维工程师
少年白char24 分钟前
【AI漫剧】开源自动化AI漫剧生成工具 - 从文字到影像:AI故事视频创作的全新可能
运维·人工智能·自动化
容智信息27 分钟前
容智Report Agent智能体驱动财务自动化,从核算迈向价值创造
大数据·运维·人工智能·自然语言处理·自动化·政务
Evan芙33 分钟前
Nginx 平滑升级
数据库·nginx·ubuntu
可涵不会debug1 小时前
时序数据库选型指南:Apache IoTDB,大数据时代的时序数据管理利器
apache·时序数据库·iotdb
眠りたいです1 小时前
Docker:容器虚拟化技术基础-namespace,cgroups,资源管理与LXC
运维·docker·中间件·容器
小周学学学1 小时前
vSphere DRS与vSphere HA
运维·服务器·vmware·虚拟化