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>
相关推荐
沐雪轻挽萤19 小时前
无人系统:Ubuntu 操作系统全景架构与实战工程指南
linux·运维·ubuntu
白緢19 小时前
嵌入式 Linux + 内核开发高频问题及排查
java·linux·运维
学编程就要猛19 小时前
JavaEE初阶:网络编程
运维·服务器·网络
hughnz19 小时前
钻井自动化案例研究
运维·自动化
ILL11IIL19 小时前
Docker容器技术
运维·docker·容器
蜡笔小新..19 小时前
Linux下Matplotlib使用Times New Roman字体的解决方案
linux·运维·matplotlib
飞yu流星19 小时前
文件压缩、文本内容、文本编辑
运维·服务器
二宝哥19 小时前
Failed connect to mirrorlist.centos.org:80; Connection refused
linux·运维·centos
JJay.20 小时前
Android App Functions 深入理解
android
Kk.080220 小时前
Linux(九)fork复制进程与写时拷贝技术
linux·运维·服务器