web.php rule,JTBC_php版本伪静态详细步骤,实现地址重写,php伪静态

、新建个记事本,内容如下,重命名为 .htaccess ,放到根目录下

RewriteEngine on

RewriteRule ^article/index.html$ article/index.php

RewriteRule ^article/detail-(.[0-9]*).html$ article/index.php?type=detail&id=$1

RewriteRule ^article/list-(.[0-9]*)-(.[0-9]*).html$ article/index.php?type=list&classid=$1&offset=$2

RewriteRule ^product/index.html$ product/index.php

RewriteRule ^product/detail-(.[0-9]*).html$ product/index.php?type=detail&id=$1

RewriteRule ^product/list-(.[0-9]*)-(.[0-9]*).html$ product/index.php?type=list&classid=$1&offset=$2

RewriteRule ^index.html$ index.php

RewriteRule ^aboutus/detail-(.[0-9]*).html$ aboutus/index.php?type=detail&id=$1

RewriteRule ^aboutus/detail-(.[0-9]*)-(.[0-9]*).html$ aboutus/index.php?type=list&classid=$1&offset=$2

这上面的代码是内容例子:  aboutus、article、product是模块名,这个容易看的懂,

RewriteRule ^aboutus/detail-(.[0-9]*)-(.[0-9]*).html$ aboutus/index.php?type=list&classid=$1&offset=$2

这个是aboutus模块分页的。其他的大家慢慢看,估计也能看的懂哪一句是哪个页面的。

RewriteRule ^index.html$ index.php 是首页伪静态重写

如果有哪个模块需要伪静态,都要参考上面的写进 .htaccess 文件里面。

2、到网站后台的系统管理——配置管理——需要伪静态的模块链接模式改为2即可,其他的不要改。

3、对上面地址重写后,需要修改链接地址,比如导航的链接地址,

拿aboutus模块的第一个id的链接地址来讲怎么写成静态地址,

上面的 aboutus/detail-(.[0-9]*).html ,这里的(.[0-9]*) 就改成1,

修改成静态地址是这样 aboutus/detail-1.html

也可以自定义添加1个链接模式就可以了

4、然后 删除缓存,比如article 模块,这个首页的地址还是article 目录,不用改,打开article模块,然后看到文章的链接都是静态的了。

RewriteEngine on

RewriteRule ^news/index.html$ news/index.php

RewriteRule ^news/detail-(.[0-9]*).html$ news/index.php?type=detail&id=$1

RewriteRule ^news/list-(.[0-9]*)-(.[0-9]*).html$ news/index.php?type=list&classid=$1&offset=$2

RewriteRule ^news/list-(.[0-9]*).html$ news/index.php?type=list&classid=$1

RewriteRule ^case/index.html$ case/index.php

RewriteRule ^case/detail-(.[0-9]*).html$ case/index.php?type=detail&id=$1

RewriteRule ^case/list-(.[0-9]*)-(.[0-9]*).html$ case/index.php?type=list&classid=$1&offset=$2

RewriteRule ^case/list-(.[0-9]*).html$ case/index.php?type=list&classid=$1

RewriteRule ^index.html$ index.php

RewriteRule ^aboutus.html$ aboutus.php

RewriteRule ^web.html$ web.php

RewriteRule ^contact.html$ contact.php

RewriteRule ^net/detail-(.[0-9]*).html$ net/index.php?type=detail&id=$1

RewriteRule ^net/detail-(.[0-9]*)-(.[0-9]*).html$ net/index.php?type=list&classid=$1&offset=$2

ErrorDocument 404 /404.html

RewriteEngine on

RewriteCond %{http_host} ^yiisu.com [NC]

RewriteRule ^(.*)$ http://www.yiisu.com/$1 [R=301,L]

~~~~~~~~~~~~~~~~~~~~~~~~···

不可以的朋友复制我的.htaccess代码,

news是文章模块,case产品模块,net是aboutus模块,下面4句是404和301重定向。

然后记得修改配置管理模块的链接模式然后删除缓存,基本上是没有问题的

我的网站http://www.yiisu.com

创建一个名字为“.htaccess”的文件。注意,“.htaccess”前面没有名字的。

但是在创建的时候却发现对记事本进行重命名的时候,记事本会提示“必须键入文件名”。到底该怎么办呢?下面说下解决办法:

方法一:

1、新建一个名字为“a.htaccess”的文本文件(txt)

2、复制下面的内容

@ren "%~f1" .*

保存为“b.bat”文本文件(txt)

把“a.htaccess”拖到b.bat文件图标上可以去掉文件名而只保留后缀,“a.htaccess”就变了“.htaccess”。

方法二:

开始-运行-键入cmd,打开cmd窗口

此时的cmd窗口路径是C:\Documents and Settings\username>

键入以下(不包括括号内信息):

copy con .htaccess (回车)

(按Ctrl+Z 回车)

屏幕提示如下:

C:\Documents and Settings\admin>copy con .htaccess

^Z

已复制 1 个文件。

此时回到桌面,双击我的电脑上进入C:\Documents and Settings\username

即可看到你想要的文件 ".htaccess"

方法一相对比较简单,各位可以根据自己的习惯进行操作。以上就是小郑的个人网站介绍的“.htaccess”重命名时提示必须键入文件名,的解决方法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值