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>
相关推荐
电棍2332 小时前
在docker a100云服务器运行vulkan->sapien->robotwin的经验(报错segmentation fault)
运维·docker·容器
alexhilton3 小时前
在Jetpack Compose中创建CRT屏幕效果
android·kotlin·android jetpack
云动雨颤4 小时前
访问宝塔面板安全入口404?SSH命令轻松解决
linux·运维·安全
NPE~4 小时前
[Linux命令分享]日志查看 — — less
linux·运维·less·常用命令·日志查看
2501_940094025 小时前
emu系列模拟器最新汉化版 安卓版 怀旧游戏模拟器全集附可运行游戏ROM
android·游戏·安卓·模拟器
大锦终5 小时前
【Linux】网络层与数据链路层中重点介绍
linux·运维·服务器·网络
下位子5 小时前
『OpenGL学习滤镜相机』- Day9: CameraX 基础集成
android·opengl
lht6319356126 小时前
从Windows通过XRDP远程访问和控制银河麒麟 v10服务器
linux·运维·服务器·windows
3DVisionary6 小时前
从手动到智能:XTOM-STATION自动化检测中心在复杂曲面零件全尺寸检测中的应用
运维·自动化·自动驾驶·工业自动化·质量控制·自动化3d测量·复杂零件检测
阿豪学编程6 小时前
环境变量与程序地址空间
linux·运维·windows