php配置伪静态如何将.htaccess文件转换 nginx伪静态文件

  php通常设置伪静态三种情况,.htaccess文件,nginx伪静态文件,Web.Config文件得形式,如何将三种伪静态应用到项目中呢,

1,.htaccess文件 实例

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
RewriteCond %{http_host} ^96net.com.cn [NC]
RewriteRule ^(.*)$ http://www.96net.com.cn/$1 [L,R=301]
</IfModule>

2, nginx伪静态文件实例

server {
listen 80;
server_name v1.ywwfx.com;
root /home/www/v1.ywwfx.com;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {
index index.php index.html index.htm;
if (!-e $request_filename) {
     rewrite ^/(.*)$ /index.php?s=$1 last; #隐藏index.php
}
}

}

3,Web.Config文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<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>
</system.webServer>
</configuration>

在项目应用得过程中,一定要看清楚好项目运行得环境。

posted @   学无边涯  阅读(1366)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示