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>
相关推荐
en-route28 分钟前
SSH Key 与 GPG Key 区别详解:Git 使用中的身份与签名机制
运维·git·ssh
ujainu35 分钟前
Flutter + OpenHarmony 网格布局:GridView 与 SliverGrid 在鸿蒙设备内容展示中的应用
android·flutter·组件
龙之叶1 小时前
【Android Monkey源码解析五】- 异常处理
android·数据库
明道源码1 小时前
Android Studio AVD 模拟器的使用与配置
android·android studio
学海无涯书山有路2 小时前
Android FragmentContainerView 新手详解(Java 版)
android·java·开发语言
上海控安2 小时前
Android生态中的SDK安全问题解析
android·安全
aidou13143 小时前
Android中自定义日期选择器样式DatePickerDialog
android·dialog·日期选择器·时间选择器·datepicker·自定义样式·timepicker
小白鸽i3 小时前
【LINUX】将源码驱动文件编译并生效
linux·运维·服务器
做萤石二次开发的哈哈3 小时前
萤石开放平台 音视频 | 产品概述
运维·服务器·萤石云·萤石·萤石开放平台
0思必得03 小时前
[Web自动化] 处理爬虫异常
运维·爬虫·python·selenium·自动化·web自动化