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>
相关推荐
tedcloud1231 小时前
OpenShip 部署指南:开源 AI 应用快速启动模板 Linux 搭建实践
linux·运维·服务器·人工智能·开源
麻瓜生活睁不开眼7 小时前
Android16修改全局桌面视图边框四直角显示为弧边圆角
android·java·深度学习
AFinalStone10 小时前
Android 7系统休眠唤醒(六)唤醒全链路
android·电源管理·休眠唤醒
晚风吹长发11 小时前
Docker基础——Docker Network(网络详解)
linux·运维·网络·ubuntu·docker·容器
雨白11 小时前
深入理解 Kotlin 协程 (九):互通有无,解构 Channel 缓冲策略与底层无锁机制
android·kotlin
LedgerNinja12 小时前
WEEX API 自动化交易实践:下单、撤单、订单查询与状态闭环
运维·自动化
灯塔@kuaidao13 小时前
平台交叉编译名词解释与基础流程
android
执笔画流年呀13 小时前
Linux搭建Java项目部署环境
java·linux·运维
Dory_Youth14 小时前
联想笔记本电脑失灵
运维·笔记·电脑
__Witheart__14 小时前
3568 Android otg模式下adb热拔插不识别
android·adb·rockchip