产品服务AMH 免费服务器主机面板SSL证书 免费SSL证书申请编程助手免费智能写代码、翻译NewAMYSQL 免费MySQL管理工具AMFTP 免费FTP管理客户端

AMH 社区首页

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

[求助帖] 求助《如何让nginx支持.htaccess》因为我不会编写伪静态规则

woaiwodemvp
铁牌会员
47.31 价值分

woaiwodemvp 发表于 2017-01-09 23:01:49
源码只提供了.htaccess 而我用的是LNMP 并且我不会写rewrite T-T哭...
网上找了如何让nginx支持.htaccess 的方法 都说让往nginx.conf 写入一段话
include /home/wwwroot/LNMP5.2/domain/xiaoshuo6/web/.htaccess;

我找到了/usr/local/nginx-generic-1.6/conf/nginx.conf 但是不让修改
(后来一想.如果加到这里.岂不是所有网站都调用了这个.htaccess)

然后我又找到了/home/wwwroot/LNMP5.2/vhost/xxxx.conf
写进去以后 AMRewrite 提示我错误
nginx: [emerg] open() "/home/wwwroot/LNMP5.2/domain/xiaoshuo6/web/.htaccess" failed (2: No such file or directory) in /home/wwwroot/LNMP5.2/vhost/xiaoshuo6.conf:10
nginx: configuration file /usr/local/nginx-generic-1.6/conf/nginx.conf test failed

这......求助各位.我该怎么办..下面是 .htaccess伪静态规则.


RewriteEngine On
#非本站域名访问的全部转到本站域名来(301跳转),请改为你自己的域名
#RewriteCond %{HTTP_HOST} !^www.b.com$ [NC]
#RewriteCond %{HTTP_HOST} !^m.b.com$ [NC]
#RewriteRule ^(.*)$ http://www.b.com/$1 [L,R=301]

#伪静态下载页
RewriteRule ^txt/(.*)\.html$ /plus/list.php?tid=$1&actype=download

#伪静态文章
RewriteRule ^(.*)/([0-9]+)\.html$ /plus/view.php?aid=$2&tdir=$1

#伪静态小说封面
RewriteCond $1 !^(dede-admin)
RewriteRule ^(.*)/$ /plus/list.php?tid=$1

#伪静态书库
RewriteRule ^shuku\.html$ /shuku.php
RewriteRule ^shuku_([0-9]+)_([0-9]+)\.html$ /shuku.php?totalresult=$1&pageno=$2
RewriteRule ^over\.html$ /shuku.php?overtag=over
RewriteRule ^over_([0-9]+)_([0-9]+)\.html$ /shuku.php?overtag=over&totalresult=$1&pageno=$2
RewriteRule ^(\w+)/shuku\.html$ /shuku.php?aid=$1
RewriteRule ^(\w+)/shuku_([0-9]+)_([0-9]+)\.html$ /shuku.php?aid=$1&totalresult=$2&pageno=$3
RewriteRule ^(\w+)/over\.html$ /shuku.php?aid=$1&overtag=over
RewriteRule ^(\w+)/over_([0-9]+)_([0-9]+)\.html$ /shuku.php?aid=$1&overtag=over&totalresult=$2&pageno=$3

#伪静态小说下载列表
RewriteRule ^txt\.html$ /txt.php
RewriteRule ^txt_([0-9]+)_([0-9]+)\.html$ /txt.php?totalresult=$1&pageno=$2
RewriteRule ^overtxt\.html$ /txt.php?overtag=overtxt
RewriteRule ^overtxt_([0-9]+)_([0-9]+)\.html$ /txt.php?overtag=overtxt&totalresult=$1&pageno=$2
RewriteRule ^(\w+)/txt\.html$ /txt.php?aid=$1
RewriteRule ^(\w+)/txt_([0-9]+)_([0-9]+)\.html$ /txt.php?aid=$1&totalresult=$2&pageno=$3
RewriteRule ^(\w+)/overtxt\.html$ /txt.php?aid=$1&overtag=overtxt
RewriteRule ^(\w+)/overtxt_([0-9]+)_([0-9]+)\.html$ /txt.php?aid=$1&overtag=overtxt&totalresult=$2&pageno=$3

#伪静态分类和作者
RewriteCond $1 !^(sitemap)
RewriteRule ^(\w+)\.html$ /plus/list.php?tid=$1

#禁止非法plus目录访问,防止攻击
RewriteCond $1 !^(search|list|view)
RewriteRule ^plus\/(\w+)\.php(.*)$ /404.html

#禁止直接访问模版
RewriteRule ^templets/(.*)/(.*).htm$ /404.html
RewriteRule ^data\/(.*)\.php(.*)$ /404.html

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A600
ExpiresByType image/x-icon A86400
ExpiresByType application/x-javascript A86400
ExpiresByType text/css A604800
ExpiresByType image/gif A86400
ExpiresByType image/png A86400
ExpiresByType image/jpeg A86400
ExpiresByType text/plain A86400
ExpiresByType application/x-shockwave-flash A86400
ExpiresByType video/x-flv A86400
ExpiresByType application/pdf A86400
ExpiresByType text/html A600
</IfModule>
评价: 这个问题有价值吗?  没有 (0分)   有, 感谢 (0分)
2017-01-09 23:01:49 1

amysql
创始人
99530.04 价值分

nginx不能用.htaccess的。
include /home/wwwroot/LNMP5.2/domain/xiaoshuo6/web/.htaccess;
这样只是用了一个.htaccess的名字,不等于支持.htaccess。

要用.htaccess的话,建议用lamp环境。
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2017-01-10 09:38:13 2

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

suppore
铝牌会员
203.76 价值分

.htaccess是Apache环境的
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (2.04分)
回复  2017-01-10 15:06:27 3

woaiwodemvp
铁牌会员
47.31 价值分

引用:
amysql 发表于 2017-01-10 09:38:13
nginx不能用.htaccess的。
include /home/wwwroot/LNMP5.2/domain/xiaoshuo6/web/.htaccess;
这样只是用了一个.htaccess的...


老大.咱的面板能不能让lamp lnmp 共存 并且域名不用加端口访问啊
评价: 这个答复有价值吗?  没有 (-4.44分)   有, 感谢 (0分)
回复  2017-01-11 22:26:01 4

amysql
创始人
99530.04 价值分

引用:
woaiwodemvp 发表于 2017-01-11 22:26:01
老大.咱的面板能不能让lamp lnmp 共存 并且域名不用加端口访问啊

如果只有一个IP。nginx与apache不能都使用80端口的。
又么你增加IP。
又么只使用nginx环境。或是apache环境。
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2017-01-12 12:46:12 5

轩少
铝牌会员
239.47 价值分

百度很多htaccess转nginx的工具的
评价: 这个答复有价值吗?  没有 (-3.19分)   有, 感谢 (0分)
回复  2017-01-18 22:18:00 6

陈小儒
铝牌会员
273.38 价值分

我就是用工具转换就可以了
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2017-02-08 17:32:35 7

流浪猫
爱猫书签
流浪猫API
流浪猫网站ICO

pigchang
铁牌会员
83.70 价值分

面板上装个amrewrite,htaccess转nginx的直接复制黏贴生效
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2017-02-22 03:03:40 8

netrob
铁牌会员
4.00 价值分

老大,我也问的是共存的问题,wdcp怎么可以实现apache+nginx双引擎呢
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2017-02-22 09:00:00 9

shiguo
铝牌会员
410.08 价值分

引用:
netrob 发表于 2017-02-22 09:00:00
老大,我也问的是共存的问题,wdcp怎么可以实现apache+nginx双引擎呢

这里不是WDCP论坛哦。这里是AMH论坛,AMH5.3支持多个环境共存。
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2017-02-22 10:07:02 10
 1 2 >  (总2页)
AMH社区列表
用户服务中心