苹果cms,maccms 关于自定义伪静态的一些二次开发

苹果cms maccms 8 有关伪静态方面列表页和详情页的自定义url

列表页的是 vod-type-id-{id}-pg-{pg} 表示的是分类id的第pg页,可以考虑根据不同的分类设置为 ,比如 type-id = 1 的是 /movie/pg-{pg}.html
比如 /movie/pg-1.html
如果 type-id=2 设置为 /tv/pg-{pg}.html,比如
/tv/pg-1.html,
我们通过修改 inc/common/template.php 的AppTpl类的getLink函数 ,在

 

$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;
return str_replace(array(‘//’,’/index’.$rgext),array(‘/’,’/’),$str);

修改为

$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;$str = $jstart . MAC_PATH . $str . $strpg . $ext. $jend;

$new_str = str_replace(array(‘//’,’/index’.$rgext),array(‘/’,’/’),$str);

// 这里增加伪静态的自定义代码比如

$new_str = preg_replace(“/vod\-type\-id\-1\-/”,”movie/”,$newstr);
// 这样是 吧 vod-type-id-1-pg-1.html 修改为  movie/pg-1.html
return $newstr;

=============================================================

同时需要修改 伪静态配置文件 .htaccess 或者 nginx的rewrite文件

RewriteRule ^movie/pg-(\d+)$   index.php\?m=vod-type-id-1-pg-$1

nginx的

rewrite ^/movie/pg-(.*)$ /index.php?m=vod-type-id-1-pg-$1  break;

 

phpcms伪静态自定义

首先增加内容模块的url定义

phpcmsurl1

然后把要启用此规则的分类设置为此规则

phpcmsurl2

修改代码 phpcms\modules\content\classes\url.class.php 修改如下内容

phpcmsurl4

增加 .htaccess

phpcmsurl3

修改的代码下载看这里

注意,以上只是例子代码, catid=6是原始phpcms里面国内新闻对应的id,你正式应用
请修改为你自己的,并且每一个 栏目的伪静态都 大概需要增加这样4行伪静态代码,

注意,不建议做多级嵌套的栏目类分类,比如 /guonei/lanmu1/  , /guonei/lanmu2/
最好只做一级目录就好了

伪静态做个记录

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

 

RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]

参考来自 http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/

nginx的下面

http://stackoverflow.com/questions/1629231/nginx-rewrite-non-www-prefixed-domain-to-www-prefixed-domain

apache 泛域名伪静态的一点备忘

匹配所有非 www bbs 开头的域名,可以匹配 111.domain.com aaa.domain.com

RewriteCond %{HTTP_HOST} ^(?!www|bbs)([^.]+).domainname.com [NC]
RewriteRule ^$   test.php?uid=%1 [QSA,L]
或者
RewriteCond %{HTTP_HOST} ^(.+)\.domainname.com$ [NC]
RewriteCond %1 !^(www|bbs)$ 
RewriteRule ^$   test.php?uid=%1 [QSA,L]

test.php 这样写

 
print_r($_GET);
 

nginx的ecshop伪静态配置

nginx 配置 ecshop 伪静态
if (!-e $request_filename)
{
rewrite "^/index\.html" /index.php last;
rewrite "^/category$" /index.php last;
rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last;
rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last;
rewrite "^/feed\.xml$" /feed.php last;
rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;
rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last;
rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;
rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last;
rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last;
rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last;
rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last;
rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;
rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last;
rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last;
rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last;
rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;
rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last;
rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last;
rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last;
rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last;
rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last;
rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last;
rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last;
rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last;
rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last;
rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;
rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last;
rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last;
}

shopex 在nginx 环境开启伪静态

core/admin/controller/sale/ctl.tools.php
搜索 test_fake_html 后面加两行如下

 $svinfo->test_fake_html(false,$msg);
 $this->system->setConf('system.seo.emuStatic','true');
 return true;

nginx 的配置文件里面

location / { 
if (!-e $request_filename) { 
rewrite ^/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ /index.php?$1 last; 
# 下面这行也可以
#rewrite ^(.*)/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ $1/index.php?$2 last;
         } 
} 
  

nginx的discuzx伪静态

discuz X 的 nginx 伪静态规则

rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
        return 404;
}

其他的建议去看
http://www.vpser.net/manage/nginx-rewrite.html