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>
相关推荐
山北雨夜漫步3 分钟前
Docker
运维·docker·容器
草莓熊Lotso6 分钟前
Qt文件操作:QFile读写全解析
运维·开发语言·c++·人工智能·qt
一路往蓝-Anbo7 分钟前
第 10 章:OpenAMP 实战——构建 M33 与 Linux 的 RPMsg 消息隧道
linux·运维·服务器·驱动开发·stm32·单片机·嵌入式硬件
Starry_hello world9 分钟前
Linux 网络(6)
linux·运维·网络
zh_xuan12 分钟前
kotlin launch函数
android·kotlin·协程·launch
贤泽34 分钟前
android 15 AOSP Broadcast 广播机制源码分析
android·aosp
啥都想学点35 分钟前
第1天:搭建 flutter 和 Android 环境
android·flutter
i建模1 小时前
通过Hyprland事件查看器(如`wev`)修改物理按键的扫描码
linux·运维
_OP_CHEN1 小时前
【Linux系统编程】(三十八)进程信号拓展:可重入函数 /volatile/SIGCHLD 全解析
linux·运维·进程·c/c++·信号·可重入函数·volatile
huohuopro1 小时前
Android WebView 输入法同步问题解决方案
android