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>
相关推荐
艾莉丝努力练剑8 小时前
【Linux:文件】进程间通信
linux·运维·服务器·c语言·网络·c++·人工智能
The森8 小时前
Linux IO模型纵深解析:文章索引
linux·运维·服务器
城东米粉儿8 小时前
Android KMP 笔记
android
小李独爱秋8 小时前
模拟面试:不能关机的情况下 , 如果挂载目录卸载不掉应该怎么办?
linux·运维·面试·职场和发展·操作系统·文件系统
锅包一切9 小时前
一、什么是Linux?
linux·运维·服务器·操作系统
ding_zhikai9 小时前
【个人日记】修复ubuntu屏幕显示不正常
linux·运维·ubuntu
学到头秃的suhian9 小时前
Docker基础扫盲
运维·docker·容器
冬奇Lab9 小时前
WMS核心机制:窗口管理与层级控制深度解析
android·源码阅读
yohalaser9 小时前
硬核智测赋能 武汉曜华激光加速钙钛矿产线产业化进程
大数据·运维·人工智能
袁袁袁袁满10 小时前
Docker后台日志和容器日志怎么查看?
linux·运维·服务器·docker·容器