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

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

娜莎兰1年前 (2023-02-08)技术588

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网站转换后的结果,网站地址(https://winginx.com/en/htaccess)经测试,这个规则才是正确的,第一个网站使用以上红色代码后,虽然网页能打开,但后台文本编辑器不能上传图片,随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回收广州市捷众电缆回收厂广东电缆回收公司广州利臻再生资源回收有限公司华亿铺发布汇...

完美修复destoon后台管理员无法登录、提示数据库错误

完美修复destoon后台管理员无法登录、提示数据库错误

destoon管理员登录后台提示数据库错误的解决方法:destoon管理员登录提示以下数据库错误:MySQL Query ErrorDuplicate entry '285955' for key 'PRIMARY' MySQL Errno:0打不开destoon后台...

浪迪加装电子助力接线图

浪迪加装电子助力接线图

如果浪迪出厂时,原厂没有助力,仪表上会少一针,一般修理师傅一看图就看明白了...

z-blog1.7更换域名

z-blog1.7更换域名没那么复杂,不像网上说的,更改一系列参数,并且可能会导致域名地址错误,造成404等诸多问题。只需在服务器后台绑定新域名,删除旧域名即可。...

z-blog搬家、换域名后出错备忘mark

一个z-blog1.7.1网站换域名,将新域名绑定到空间,新域名打开网页正常。z-blog后台的网站设置及一些路径自动更换为新网址。重建一个网站,将新域名绑定,将老空间的网站文件和数据库分别迁移到新域名的空间和数据库上,复制老空间的nginx的伪静态规则到新空间,打开新域名的网页都正常。之前看到网上...

z-blog修改伪静态路径和字符备忘

打开后台“网站设置”-“静态化管理中心”,点选“伪静态”。将“文章的URL配置”后面同一行的“{%host%}post/{%id%}.html”更改为想要的内容即可。如{%host%}html/{%id%}.html...