当前位置:首页 > 技术 > 正文内容

Destoon7.0网站搬家Apache转换Nginx伪静态遇到的问题备忘录

娜莎兰1个月前 (02-08)技术66

2023年2月7日晚,几个Destoon网站在Windows 2008 Server 上由于Apache占用资源太多,网站打开不理想,所以重装了CentOS7系统,使用轻量级的nginx+宝塔,由于在Windows系统中修改过.htaccess中的伪静态规则,搬家到CenOS系统上,网站详情页都打不开,全部404。


第一个网站的.htaccess 伪静态规则使用宝塔的Apache转Nginx后,仍然是404,测试Destoon里的.htaccess、以及网上许多nginx的规则还是不行。第二天起床后查看伪静态规则,问题出在以下规则上:

RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4  #这是destoon的

RewriteRule ^(.*)/     ([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4  #这是之前Apache的,就是这行出的问题。

   rewrite ^/(.*)/show-([0-9]+)([-])?([0-9]+)?.html$ /$1/show.php?itemid=$2&page=$4 last;  #这是这个https://www.laike.net/article-15-71774-0.html 网站的,已测此伪静态规则在刚刚安装的destoon程序中可用。

将该网站上的nginx伪静态规则去除”show-“这几个字符后,网页可以正常打开了。


第二个网站,记得多年前弄伪静态规则的时候,第二个和第一个的伪静态规则是一模一样的,可能记不清楚了,于是将两个伪静态规则对照查看,确实一模一样,将第一个正常的贴入第二个网站,内页却打不开,又404了。查看网址,两个网站的网址并不一样。

第一个是这样的:http://www.***.com/info/12345.html

第二个是这样的:http://www.***.com/view-12345.html


于是将第二个网站之前Apache的伪静态规则贴入宝塔的Apache转Nginx,将转换后的规则放入第二个网站,网页正常打开了。


第三个DT,.htaccess伪静态规则是DT默认的,没有修改过。完整贴入上面所说某网站的nginx规则,网页正常打开。


娜莎兰-李凌云-记之以备忘。归纳:不同问题要不同对待!


附:

以下是上面所说某网站的nginx规则,该规则在初始安装DT后一切正常。

rewrite ^/(.*).(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php last;

rewrite ^/(.*)/file/(.*).php(.*)$ /404.php last;

rewrite ^/(.*)-htm-(.*)$ /$1.php?$2 last;

rewrite ^/(.*)/show-([0-9]+)([-])?([0-9]+)?.html$ /$1/show.php?itemid=$2&page=$4 last;

rewrite ^/(.*)/list-([0-9]+)([-])?([0-9]+)?.html$ /$1/list.php?catid=$2&page=$4 last;

rewrite ^/(.*)/show/([0-9]+)/([0-9]+)?([/])?$ /$1/show.php?itemid=$2&page=$3 last;

rewrite ^/(.*)/list/([0-9]+)/([0-9]+)?([/])?$ /$1/list.php?catid=$2&page=$3 last;

rewrite ^/(.*)/([A-za-z0-9_-]+)-c([0-9]+)-([0-9]+).html$ /$1/list.php?catid=$3&page=$4 last;

rewrite ^(.*)/([a-z]+)/(.*).shtml$ $1/$2/index.php?rewrite=$3 last;

rewrite ^/(com)/([a-z0-9_-]+)/([a-z]+)/(.*).html$ /index.php?homepage=$2&file=$3&rewrite=$4 last;

rewrite ^/(com)/([a-z0-9_-]+)/([a-z]+)([/])?$ /index.php?homepage=$2&file=$3 last;

rewrite ^/(com)/([a-z0-9_-]+)([/])?$ /index.php?homepage=$2 last;


以下是国外某网站Apache转Nginx转换后的结果,经测试,这个规则才是正确的,第一个网站使用以上红色代码后,虽然网页能打开,但后台文本编辑器不能上传图片,随html粘贴的图片显示图片缺失,帖子缩略图图片也不能正确显示。以下规则使用正常,暂时没有检测到bug:

# nginx configuration by winginx.com error_page 404 /404.php; location / {  rewrite ^/(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php;  rewrite ^/(.*)-htm-(.*)$ /$1.php?$2;  rewrite ^/(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ /$1/show.php?itemid=$2&page=$4;  rewrite ^/(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ /$1/list.php?catid=$2&page=$4;  rewrite ^/(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ /$1/list.php?catid=$3&catdir=$2&page=$4;  rewrite ^/(.*)/show/([0-9]+)/([0-9]+)?([/])?$ /$1/show.php?itemid=$2&page=$3;  rewrite ^/(.*)/list/([0-9]+)/([0-9]+)?([/])?$ /$1/list.php?catid=$2&page=$3;  rewrite ^/(.*)/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /$1/index.php?moduleid=$2&catid=$3&itemid=$4&page=$5;  rewrite ^/(.*)/([a-z]+)/(.*)\.shtml$ /$1/$2/index.php?rewrite=$3; } location /admin {  rewrite ^(.*)$ /404.php; } location /cache {  rewrite ^(.*)$ /404.php; } location /file {  rewrite ^(.*)$ /404.php; } location /include {  rewrite ^(.*)$ /404.php; } location /lang {  rewrite ^(.*)$ /404.php; } location /module {  rewrite ^(.*)$ /404.php; } location /skin {  rewrite ^(.*)$ /404.php; } location /template {  rewrite ^(.*)$ /404.php; } location /com {  rewrite ^/(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ /index.php?homepage=$2&file=$3&rewrite=$4;  rewrite ^/(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$ /index.php?homepage=$2&file=$3;  rewrite ^/(com)/([a-z0-9_\-]+)([/])?$ /index.php?homepage=$2; }


“Destoon7.0网站搬家Apache转换Nginx伪静态遇到的问题备忘录” 的相关文章

关于养站的一个大胆设想

使用一个独立的云服务器,使用多个域名建设多个织梦站,因为织梦程序漏洞较多,网站建好后不长时间,就会被挂马。挂马的网站会被黑客持续优化......然后,我们坐享其成!...

网站备忘录

乐收购爱发布好回收广州供销电缆回收公司广州永鑫物资回收公司广州利臻电池回收蓄电池回收|电瓶回收|UPS回收广州市捷众电缆回收厂广东电缆回收公司广州利臻再生资源回收有限公司华亿铺发布汇...

修罗xiuno BBS伪静态Apache注意事项

1.  将下面代码写入根目录的.htaccess文件保存RewriteEngine onRewriteBase /RewriteCond %{HTTP_USER_AGENT} YisouSpider [NC,OR]RewriteCond %{HTTP_USER_AGENT} ^EasouS...

床车改装磷酸铁锂副电瓶最佳简单改装方案备忘录

通过网络多次查询专家和实际改装爱好者的各种方案,得出最佳方法,电器设备安装简单,不占空间,备忘如下:采用遥控直流继电器(专家说购买12V300安的,搜索淘宝未找到,有待继续探讨)+稳压恒流充电器,以上两个设备安装在发动机舱,使用普通平方电线,给备用电瓶充电,使用磷酸铁锂的话,可将稳压恒流充电器的充电...

xiuno标题SEO的优化修改方法

首页翻页,无论你翻到第几页,标题都是一样的,而且还是主站的标题,这样搜索引擎收录上千页面,标题都是网站标题,影响大不大,自己想了。下面提供个我自己用的修改方法,如果有大神有更好的方法,也希望提供下。改动文件:route/index.php原来代码:$header['title'] =...

XiunoBBS强制外链在新窗口打开并有安全提示的功能

JS代码放到全局内容页尾(全局 : html > body ( footer_js_after ))<script>!function() {$("a").each(function() {var url = $(this).attr('href'...