跳至主要内容

帝国cms使用wap版手机网站伪静态实现方法

帝国cms的wap功能是一个实现手机版比较边界且自由度高的方法,但这其中也有一些问题,就是地址只有动态地址,这样对收录似乎并不好。

这里我们以这套模板的wap端为例,来讲一下帝国cms的wap端实现伪静态的方法。

一、wap端模板的路径

首先我们说明一下,wap端的模板是存储在文件当中,地址为 /e/wap/template/ ,这其中有index.temp.php  list.temp.php  show.temp.php,分别对应首页、列表页、内容页。

二、文件修改

我们打开index.temp.php文件,也就是首页模板,其中list.php为列表页链接,show.php为内容页链接。

我们在第31行看到如下代码:

$classurl="list.php?classid=".$r[classid]."&style=".$wapstyle."&bclassid=".$bclassid;

假设我们要把地址伪静态为 /e/wap/list-8.html ,我们将上面的链接代码修改为如下:其中classid即栏目id,style和bclassid对应模板样式和父栏目id,这两项可不填写。

$classurl="list-".$r[classid]."html";

接下来是内容页链接地址,内容页地址是在wap版灵动标签中通过函数生成,函数在/e/wap/wapfun.php文件第527行,代码如下:其他地方类似,包含list链接的地方都修改为如上的方式。

$titleurl='show.php?classid='.$r[classid].'&id='.$r[id].'&style='.$wapstyle.'&bclassid='.$class_r[$r[classid]

我们也将其修改为静态化的地址,这里需要注意,classid及id两项为必须,其他可忽略:

$titleurl='show-'.$r[classid].'-'.$r[id].'.html';

上面是首页及灵动标签中地址的修改,接下来我们看列表页,打开list.temp.php文件,其中的代码与上面类似,修改方式可参考上方,例如第52行定义的内容页地址:我们也将其修改为静态化的地址,这里需要注意,classid及id两项为必须,其他可忽略:

$titleurl="show.php?classid=".$r[classid]."&id=".$r[id]."&style=".$wapstyle."&cpage=".$page."&cid=".$classid."&bclassid=".$bclassid;

文件修改完之后,我们还需要相应的伪静态规则来实现地址链接的rewrite,大家可根据自己的服务器环境选择。三、伪静态规则

apache:

Options +FollowSymLinks
RewriteEngine on 

RewriteRule ^(.*)/e/wap/index.html$ $1/e/wap/index.php 
RewriteRule ^(.*)/e/wap/list-([0-9]+).html$ $1/e/wap/list.php?classid=$2 
RewriteRule ^(.*)/e/wap/show-([0-9]+)-([0-9]+).html$ $1/e/wap/show.php?classid=$2&id=$3 

nginx:

location / { 
rewrite ^(.*)/e/wap/index.html$ $1/e/wap/index.php 
rewrite ^(.*)/e/wap/list-([0-9]+)\.html$ $1/e/wap/list.php?classid=$2 
rewrite ^(.*)/e/wap/show-([0-9]+)-([0-9]+)\.html$ $1/e/wap/show.php?classid=$2&id=$3 
 } 

 

评论

此博客中的热门博文

利用haproxy来做V2RAY负载均衡

Sandy在之前有说过 阿里云通过Nginx中转Linode/digitalocean/AWS的V2ray协议,实现负载均衡 ,有些学童不想折腾nginx,那么我们可以用haproxy来折腾,不管是haproxy还是Nginx都可以在树莓派和局域网的PC机器折腾! 安装haproxy的教程就移步到-> haproxy安装教程 apt-get install haproxy 安装完毕,我们来修改haproxy的配置 vi /etc/haproxy/haproxy.cfg 里面内容全部删除,加入下面的内容 global ulimit-n 51200 log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy pidfile /var/run/haproxy.pid user haproxy group haproxy daemon defaults log global mode tcp retries 3 option dontlognull option redispatch #上游TCP服务器连接等待时间 timeout connect 5s timeout client 24h timeout server 24h #以下为Web管理页面设置,如不需要可以删除 listen admin_stats bind 0.0.0.0:8888 mode http log 127.0.0.1 local0 err stats refresh 30s stats uri /haproxy stats realm welcome login\ Haproxy stats auth admin:admin stats hide-version stat...

阿里云通过Nginx中转Linode/digitalocean/AWS的V2ray协议,实现负载均衡

开篇文的废话.原因是Sandy做站服务器太多了,发现利用率不高,皮又痒了又想折腾了.v2ray是利器但是给人的感觉就是只能用一台服务器,官方也说不支持负载均衡,不会A服务器挂机,自动跳转到B服务器.这里就有点折磨人了.每个服务器挂了都要自己去改配置文件. 我们访问国外的服务器,如果没CN2的线路是非常慢的,起码不快!哈哈~现在VPS都便宜起码人手一个人有5台以上吧?这样的话我们就可以开整. 开整条件:国内VPS或者阿里云有CN2线路的机器最好是100MB-200MB的带宽的.保证你爽歪歪.但是Sandy在阿里云HK30MB下也测试了也可以达到30000KB以上,羡慕吧~我们可以开始了! 老规则工具先出: 没被gwf和谐的服务器1台(下文统称:主服务器) 国外服务器2台以上(下文统称:从服务器) nginx 1.9.5版本以上(推荐:lnmp1.4) v2ray croe 第一步: 在 主服务器 安装lnmp1.4,这里就不细说教程了.直接去 官方 看教程 安装完毕以后我们来升级Nginx让他支持stream模块 cd lnmp1.4 vi lnmp.conf 在Nginx_Modules_Options=‘’里面加入--with-stream Nginx_Modules_Options='--with-stream’ 然后执行升级命令 ./upgrade.sh nginx  第二步 修改nginx.conf文件 cd /usr/local/nginx/conf/nginx.conf 在 events { use epoll; worker_connections 51200; multi_accept on; } 下面加入 stream{ server{ listen 0.0.0.0:8080; proxy_pass v2ray_backend; proxy_timeout 10m; proxy_connect_timeout 5000ms; } upstream v2ray_backend{ server ...

ssh over socks5:通过socks5 proxy来连接ssh服务器[转载]

最近因为不可描述的原因,我在aws soul的云主机访问不了,ssh、80、ss全部都被禁掉了。 80端口在chrome配置SwitchyOmega就可以了,但ssh不太好办,shell上配置http_proxy对ssh没什么用。 其实ssh自己就支持proxy。 注意这跟在ssh端口转发:远程和本地中介绍过使用ssh作为proxy的方法不同,ssh -D是为了用ssh做proxy,而不是通过proxy来连接ssh服务器。 TL;DR ssh -o ProxyCommand='nc -x 192.0.2.0:1080 %h %p' user@awshost 原理解析 $ man ssh_config ProxyCommand Specifies the command to use to connect to the server. The command string extends to the end of the line, and is executed using the user's shell ‘exec’ directive to avoid a lingering shell process. In the command string, any occurrence of ‘%h’ will be substituted by the host name to connect, ‘%p’ by the port, and ‘%r’ by the remote user name. The command can be basically anything, and should read from its standard input and write to its standard output. It should eventually connect an sshd(8) server running on some machine, or execute sshd -i somewhere. Host key management will be done using the HostName of the host being connected (defa...