Nginx配置伪静态,URL重写

Nginx配置伪静态,URL重写

Nginx

在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:

复制代码
location / { // …..省略部分代码
   if (!-e $request_filename) {
           rewrite  ^(.*)$  /index.php?s=/$1  last;
    }
}

IIS

如果你的服务器环境支持ISAPI_Rewrite的话,可以配置httpd.ini文件,添加下面的内容:

复制代码
RewriteRule (.*)$ /index\.php\?s=$1 [I]

在IIS的高版本下面可以配置web.Config,在中间添加rewrite节点:

复制代码
<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>

IIS URL重写,导入规则

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*) index.php?s=1 L

Apache

  1. httpd.conf配置文件中加载了mod_rewrite.so模块
  2. AllowOverride None 将None改为 All
  3. 把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下
复制代码
<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>
相关推荐
Decay__2 小时前
PostgreSQL 用户权限与安全 —— 角色体系、GRANT 授权、pg_hba.conf 认证、行级安全与审计
运维·数据库·sql·postgresql
StarsGreen2 小时前
Android VINTF 中 Device Manifest 与 Framework Manifest 详解
android
fengkai45452 小时前
Python运维实战
运维·开发语言·python·ssh·sftp·paramiko
那明眸似水3 小时前
LVS高可用负载均衡集群部署实训
运维·负载均衡·lvs
MSTcheng.3 小时前
【LinuxIO篇】Linux学习第二十三弹——fopen和open有什么区别?从 FILE* 到 fd,讲透 Linux 文件 IO
linux·运维·学习·io·系统调用·fd
charliejohn3 小时前
计算机考研 408 网络 DNS 概念
运维·服务器·网络
Name_NaN_None4 小时前
安卓手机远程控制电脑方法(Android/Windows) —— 「小白教程」
android·windows·智能手机·电脑·笔记本
BullSmall4 小时前
Jenkins Git插件报错?6步修复+预防指南
运维·jenkins
恋猫de小郭4 小时前
Flutter Perfetto:Dart Heap Sampling 终于要接入 Android 原生内存分析了
android·前端·flutter
分布式存储与RustFS4 小时前
向量库快照只落在本地盘:换节点恢复时把 RustFS 桶当副本源
运维·云原生·开源·对象存储·分布式存储·s3·性能基准