产品服务AMH 免费服务器主机面板SSL证书 免费SSL证书申请 担保单 免费安全、零费率交易平台编程助手免费智能写代码、翻译AMYSQL 免费MySQL管理工具

AMH 社区首页

 AMH社区 - 开放自由有价值的社区

[求助帖] 请教appache服务器转到amh lnmp环境后的伪静态问题

hongzm
铝牌会员
229.00 价值分

hongzm 发表于 2015-11-04 00:46:42
请教各位高手一个问题!
我有一台旧服务器是自己装的环境,用的appche,想换成amh的lnmp环境,但有一个网站出现404错误,应该是伪静态造成的。
该网站根目录下.htaccess内容如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond % !^$
RewriteRule ^index\.html$ /index.php [NC,L]

RewriteRule ^(.*)/(.*)/$ /index\.php\?$1&nid=$2 [NC,L]
RewriteRule ^(.*)/(.*)/index.html$ /index\.php\?$1&nid=$2 [NC,L]
##RewriteRule ^(.*)/a([0-9]+)\.html$ /index.php?$1&article_id=$2 [NC,L]
RewriteRule ^(.*)/detail/([0-9]+)$ /index.php?$1&article_id=$2 [NC,L]
RewriteRule ^(.+)/$ /index.php?$1 [NC,L]
RewriteRule ^(.+)/index.html$ /index.php?$1 [NC,L]

##表单提交/反馈
RewriteRule ^info/add/s01$ index.php?info&q=code/add/save_f/ [NC,L]
RewriteRule ^info/add/s02$ index.php?info&q=code/add/save_j/ [NC,L]

##imgcode
RewriteRule ^plugins/imgcode$ /index.php?plugins&q=imgcode&t$1 [NC,L]
RewriteRule ^plugins/imgcode/(.*)$ /index.php?plugins&q=imgcode&t$1 [NC,L]

##user
RewriteRule ^user/reg/$ /index\.php\?user&q=reg [NC,L]
RewriteRule ^user/login/$ /index\.php\?user&q=reg [NC,L]
##RewriteRule ^user/(.*)/$ /index\.php\?user&q=$1 [NC,L]

##RewriteRule ^(.*)/user/(.*)/(.*)/(.*)$ $1/index\.php\?user&user_id=$2&q=code/$3/$4 [NC,L]
##RewriteRule ^(.*)/user/(.*)/(.*)$ $1/index\.php\?user&user_id=$2&q=code/$3 [NC,L]
##RewriteRule ^(.*)/user/(.*)$ $1/index\.php\?user&user_id=$2 [NC,L]
##RewriteRule ^(.*)/u/(.*)/(.*)$ $1/index\.php\?home&user_id=$2&q=$3 [NC,L]
##RewriteRule ^(.*)/u/(.*)$ $1/index\.php\?home&user_id=$2 [NC,L]
##RewriteRule ^(.*)/(.*)/index.html\?(.*)$ $1/index\.php\?$2&$3 [NC,L]
##RewriteRule ^(.*)/(.*)/(.*)/index.html$ $1/index\.php\?$2&nid=$3 [NC,L]
##RewriteRule ^(.*)/(.*)/(.*)/index(.*).html$ $1/index\.php?$2&nid=$3&page=$4 [NC,L]
##RewriteRule ^(.*)/(.*)/(.*)/a(.*).html$ $1/index\.php\?$2&nid=$3&article_id=$4 [NC,L]
##RewriteRule ^(.*)/(.*)/(.*)/a(.*).html?(.*)$ $1/index\.php\?$2&nid=$3&article_id=$4&$5 [NC,L]
##RewriteRule ^(.*)/(.*)/index.html$ $1/index\.php\?$2 [NC,L]
##RewriteRule ^(.*)/(.*)/index(.*).html$ $1/index\.php\?$2&page=$3 [NC,L]
##RewriteRule ^(.*)/(.*)/index(.*).html?(.*)$ $1/index\.php\?$2&page=$3&$4 [NC,L]
##RewriteRule ^(.*)/(.*)/a(.*)_(.*).html$ $1/index\.php\?$2&article_id=$3&page=$4 [NC,L]
##RewriteRule ^(.*)/(.*)/a(.*).html$ $1/index\.php\?$2&article_id=$3 [NC,L]
##RewriteRule ^(.*)/(.*)/a(.*).html?(.*)$ $1/index\.php\?$2&article_id=$3&$4 [NC,L]

##RewriteRule ^(.+)/index\.html$ /index.php?$1 [NC,L]
##RewriteRule ^(.*)/index.html\?(.*)$ $1/index\.php\?$2&$3 [NC,L]
##RewriteRule ^(.*)/a([0-9]+)\.html$ /index.php?$1&article_id=$2 [NC,L]
RewriteRule ^(.*)/index(.*).html$ /index.php?$1&page=$2
##RewriteRule ^u/([0-9]+)$ /index.php?home&user_id=$2&q=$3 [NC,L]
</IfModule>

请教我如何才能转换到目前的AMH5.2 LNMP环境里。是不是转成AMREWIRTE里的.CONF,如果是,该如何转啊。我在网上用得在线转换工具,转换了好像没有用。如有回答,不胜感激!



2015-11-04 00:46:42 1

诸葛御风
金牌会员
5691.90 价值分

安装AMRewrite在对应环境中添加伪静态规则
# nginx configuration
location /index {
rewrite ^/index\.html$ /index.php break;
}
location / {
rewrite ^/(.*)/(.*)/$ /index\.php\?$1&nid=$2 break;
rewrite ^/(.*)/(.*)/index.html$ /index\.php\?$1&nid=$2 break;
rewrite ^/(.*)/detail/([0-9]+)$ /index.php?$1&article_id=$2 break;
rewrite ^/(.+)/$ /index.php?$1 break;
rewrite ^/(.+)/index.html$ /index.php?$1 break;
rewrite ^/(.*)/index(.*).html$ /index.php?$1&page=$2;
}
location = /info/add/s01 {
rewrite ^(.*)$ /index.php?info&q=code/add/save_f/ break;
}
location = /info/add/s02 {
rewrite ^(.*)$ /index.php?info&q=code/add/save_j/ break;
}
location = /plugins/imgcode {
rewrite ^(.*)$ /index.php?plugins&q=imgcode&t$1 break;
}
location /plugins {
rewrite ^/plugins/imgcode/(.*)$ /index.php?plugins&q=imgcode&t$1 break;
}
location = /user/reg {
rewrite ^(.*)$ /index\.php\?user&q=reg break;
}
location = /user/login {
rewrite ^(.*)$ /index\.php\?user&q=reg break;
}
这是对于转换过来的规则
http://www.winginx.com/en/htaccess 转换地址
另外安利下我司CDN服务 www.jiasulo.com
买CDN防护可送高端VPS做源
  支持 (0分)  反对 (0分)
回复  2015-11-04 00:59:29 2

hongzm
铝牌会员
229.00 价值分

谢谢你的回答:)
我使用了此代码放在主机对应的conf文件里,重裁nginx,但伪静态页面还是显示404。不知道为什么
  支持 (0分)  反对 (0分)
回复  2015-11-04 10:32:21 3

amysql
创始人
99530.81 价值分

要看你是哪个页面404,排查规则是否有匹配到这个URL。
  支持 (0分)  反对 (0分)
回复  2015-11-13 17:47:59 4

AMH面板 - 好用高效低占用、安全可靠极稳定

 1  (总1页)
AMH社区列表
用户服务中心