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

相关推荐
漫谈网络1 分钟前
基于 Netmiko 的网络设备自动化操作
运维·自动化·netdevops·netmiko
꧁坚持很酷꧂28 分钟前
Linux Ubuntu18.04下安装Qt Craeator 5.12.9(图文详解)
linux·运维·qt
小诸葛的博客2 小时前
详解Linux中的定时任务管理工具crond
linux·运维·chrome
一默19912 小时前
CentOS 7.9升级OpenSSH到9.9p2
linux·运维·centos
BranH3 小时前
Linux系统中命令设定临时IP
linux·运维·服务器
极小狐3 小时前
极狐GitLab 项目功能和权限解读
运维·git·安全·gitlab·极狐gitlab
宁酱醇3 小时前
GitLab_密钥生成(SSH-key)
运维·ssh·gitlab
秋风起,再归来~3 小时前
【Linux庖丁解牛】—进程优先级!
linux·运维·服务器
Lalolander4 小时前
设备制造行业如何避免项目管理混乱?
运维·制造·工程项目管理·四算一控·epc·环保设备工程·设备制造
LucianaiB4 小时前
【金仓数据库征文】_AI 赋能数据库运维:金仓KES的智能化未来
运维·数据库·人工智能·金仓数据库 2025 征文·数据库平替用金仓