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>
相关推荐
峥嵘life3 分钟前
Android16 EDLA中GMS导入和更新
android·linux·学习
电棍2335 分钟前
AUTODL服务器环境配置和下载数据概述
运维·深度学习·uv
Huanzhi_Lin13 分钟前
验证apk签名
android·apk签名·apksigner
独自破碎E24 分钟前
【大顶堆+小顶堆】数据流中的中位数
android
haluhalu.40 分钟前
深入理解Linux信号机制:中断、用户态与内核态
linux·运维·服务器
二哈喇子!43 分钟前
Linux系统配置jdk
linux·运维·服务器·jdk
得一录1 小时前
Android AIDL 在智能体和IOT设备中的使用
android·人工智能·物联网·aigc
-KamMinG1 小时前
亲自面试版运维面试题(按需更新)
运维·面试·职场和发展
BullSmall1 小时前
ELK 单机版日志系统【一键自动化部署脚本 + 完整配套配置】
运维·elk·自动化
zhengxianyi5151 小时前
vite build 发布到nginx二级目录——将yudao-ui-go-view打包、部署到big目录下
vue.js·nginx·vite·前后端分离·打包·ruoyi-vue-pro优化·部署运维