投稿 评论 顶部

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>

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