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 NoneNone改为 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>
相关推荐
cxr8289 分钟前
龙虾长程任务测试 —— 撰写零人公司自动化运营实践研究报告
运维·人工智能·自动化·openclaw
杨云龙UP12 分钟前
MySQL慢查询日志暴涨导致磁盘告警:slow query log膨胀至397G的生产故障排查:清理、参数优化
linux·运维·服务器·数据库·mysql
android_cai_niao14 分钟前
Android中有什么技术过时了可以直接用新技术的
android·过时技术
chQHk57BN20 分钟前
DeepFlow Agent 故障排查指南:注册失败、协议解析、资源识别与配置方式
linux·运维·服务器
@土豆38 分钟前
基于Docker部署Squid正向代理文档
运维·docker·容器
lingggggaaaa1 小时前
PHP原生开发篇&文件安全&上传监控&功能定位&关键搜索&1day挖掘
android·学习·安全·web安全·php
数据知道1 小时前
claw-code 源码详细分析:Remote / SSH / Teleport / Deep Link——运行时分支爆炸怎样用「模拟模式」先收束状态机?
运维·ai·ssh·claude code
LSL666_1 小时前
Linux命令
linux·运维·服务器
我是场1 小时前
我的NPI项目 - OTA upgrade是什么?
android·人工智能
zh_xuan1 小时前
Android 实现fragment导航
android·fragment导航