首页 > 帮助中心 > 网站建设相关问题 > WIN和Nginx之间的伪静态规则互相转换方法

资讯分类



WIN和Nginx之间的伪静态规则互相转换方法

日期:2017-11-24    共阅 [ 2219 ] 次

.htAccess和httpd.ini和Nginx之间的伪静态规则互相转换方法


经常换服务器,所以这些规则也需要互转。查询了很多,百度谷歌了也一堆,没有一个说明的文档,特自己趁热打铁把刚刚研究的成果记下来 已备以后查询!
httpd.ini  举例一个
-----------------------------------------------------------------------------------------------------------
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# duoduo Rewrite规则
RewriteRule ^/index.html$ /index.php
RewriteRule ^/sitemap.html$ /sitemap.php
RewriteRule ^/malllist.html$ /malllist.php
-----------------------------------------------------------------------------------------------------------
转换成 .htaccess  注意看不同点 下次按照这样转换即可。
-----------------------------------------------------------------------------------------------------------
RewriteEngine On
RewriteBase /
# duoduo Rewrite规则
RewriteRule index.html$ /index.php
RewriteRule sitemap.html$ /sitemap.php
RewriteRule malllist.html$ /malllist.php
-----------------------------------------------------------------------------------------------------------
httpd.ini 转换 .htaccess  一般规则说明:
1.
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
换成:
RewriteEngine On
RewriteBase /
2.
RewriteRule ^/index.html$ /index.php
去掉 ^/
RewriteRule index.html$ /index.php
-----------------------------------------------------------------------------------------------------------
.htaccess  转换成 nginx  注意看不同点 下次按照这样转换即可。
-----------------------------------.htaccess-----------------------------------------------------
RewriteEngine On
RewriteBase /
# duoduo Rewrite规则
RewriteRule index.html$ /index.php
RewriteRule sitemap.html$ /sitemap.php
RewriteRule malllist.html$ /malllist.php
------------------------------------nginx----------------------------------------------------------
location / {
rewrite /index.html$ /index.php last;
rewrite /sitemap.html$ /sitemap.php last;
rewrite /malllist.html$ /malllist.php last;-
----------------------------------------------------------------------------------------------------------
.htaccess  转换成 nginx  说明
-----------------------------------------------------------------------------------------------------------
1.
RewriteEngine On
RewriteBase /
# duoduo Rewrite规则
转换为:
location / {
2.
RewriteRule index.html$ /index.php
转换为:
rewrite /index.html$ /index.php last;
-----------------------------------------------------------------------------------------------------------
送上在线转换的地方:


.htaccess Editor  :http://www.htaccesseditor.com/sc.shtml


把.htaccess中的规则自动转换成nginx
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/


综合转换:http://www.onexin.net/rewrite.php


不可思议,将URL Rewrite规则正向或反向转换,适用于Apache,Lighttpd,IIS,Nginx环境下伪静态。


示例:

Nginx rewrite references e.g.

  1. rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;

Apache rewrite e.g.

  1. RewriteRule ^store-([0-9]+)\.html$ store.php?id=$1 [L,NC]

IIS rewrite (WordPress)
  1. [ISAPI_Rewrite]

  2. # 3600 = 1 hour

  3. CacheClockRate 3600

  4. RepeatLimit 32


  5. RewriteRule ^index\.php$ - [L]

  6. RewriteCond %{REQUEST_FILENAME} !-f

  7. RewriteCond %{REQUEST_FILENAME} !-d

  8. RewriteRule . /index.php [L]

Apache rewrite (WordPress)

  1. RewriteEngine On

  2. RewriteBase /

  3. RewriteRule ^index\.php$ - [L]

  4. RewriteCond %{REQUEST_FILENAME} !-f

  5. RewriteCond %{REQUEST_FILENAME} !-d

  6. RewriteRule . /index.php [L]

Nginx rewrite (Wordpress)

  1. location / {

  2. index index.html index.php;

  3. if (-f $request_filename/index.html){

  4. rewrite (.*) $1/index.html break;

  5. }

  6. if (-f $request_filename/index.php){

  7. rewrite (.*) $1/index.php;

  8. }

  9. if (!-f $request_filename){

  10. rewrite (.*) /index.php;

  11. }

  12. }

相关文章:http://www.cpoo.com.cn/article/show_103.html



 

 

基础产品服务
域名注册
虚拟主机
云服务器
企业邮箱
服务器托管
服务器租用
网站营销
智能建站
产品管理平台
企业解决方案
400电话
网站建设
在线客服系统
服务器运维
优化营销
数据恢复
Mysql数据库
SQL数据库
技术文档
合同文本
站长必备软件
实例与代码
代理文档
精品作品
站长论坛
展览馆
HTML5炫
关键词密度分析
IP归属地查询
备案查询
SEO查询
百度权重查询
solidworks
保持接触
联系电话:15810326078
010-68924881
技术QQ:12491287
商务QQ:22392247
技术邮箱: cpoo@163.com
联系方式
畅景论坛
客服&帮助
扫码领红包
新闻公告
代理加盟
如何网站备案
付款方式
索取发票
渠道合作
帮助中心
网站地图

微信咨询/联系:

↑ 扫描加微信咨询

北京辟谣平台 违法不良信息举报

关于畅景| 联系我们| 付款方式| 网站备案| 帮助中心| 畅景资讯| 相关下载 ||||
本站产品全面支持在线支付,自主开通及管理! 域名注册,域名查询,域名申请,虚拟主机,企业邮箱,网站建设,云主机,网络推广尽在畅景互联
版权所有 www.cpoo.com.cn 京ICP备12015531号-8 京公网安备110105018078   北京新网(Xinnet.com)认证注册服务机构 新网授权代理商

十年历史见证 超过9000家客户信誉保障 腾讯在线QQ客服:12491287 22392247

客户服务中心(7×24):15810326078 传真:010-68924881-2288