VPS侦探论坛

 找回密码
 注册
查看: 9483|回复: 9

求助军哥 二级域名泛解板

[复制链接]
发表于 2011-7-27 13:11:16 | 显示全部楼层 |阅读模式

我有一个B2B 和一个论坛我将*.abc.com邦定到子目(公司目录company)又想将dd.abc.com邦到论坛(一级目录)
我在apach设置成
  1. <VirtualHost *:88>
  2. ServerAdmin webmaster@example.com
  3. php_admin_value open_basedir "/home/wwwroot/abc:/tmp/:/var/tmp/:/proc/"
  4. DocumentRoot "/home/wwwroot/abc/"
  5. ServerName www.abc.com
  6. RewriteEngine On
  7.     ErrorDocument 404 /404.php
  8.     RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
  9.     RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
  10.     RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4
  11.     RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4
  12.     RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3
  13.     RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
  14.     RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?/$ $1/show.php?itemid=$2&page=$4
  15.     RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?/$ $1/list.php?catid=$2&page=$4
  16. #ErrorLog "logs/-error_log"
  17. #CustomLog "logs/-access_log" common
  18. </VirtualHost>

  19. <VirtualHost *:88>
  20. ServerAdmin webmaster@example.com
  21. php_admin_value open_basedir "/home/wwwroot/abc:/tmp/:/var/tmp/:/proc/"
  22. DocumentRoot "/home/wwwroot/abc/company/"
  23. ServerName abc.com
  24. ServerAlias  *.abc.com
  25. RewriteEngine On
  26.     ErrorDocument 404 /404.php
  27.     RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
  28.     RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3
  29. #ErrorLog "logs/-error_log"
  30. #CustomLog "logs/-access_log" common
  31. </VirtualHost>
复制代码
这样做是成功了泛解析到子目录(公司目录company)但是dd.abc.com无法转到论坛,404一直转到错误页面

问军哥,有办法实现泛解析后还能用子域名帮定到论坛吗?
还有上面这段代码设置完后还要在nignx设置什么吗?

这是nignx的设置
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name 668ph.com wwww.abc.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/abc;

  7.                 location / {
  8.                         try_files $uri @apache;
  9.                         }

  10.                 location @apache {
  11.                         internal;
  12.                         proxy_pass http://127.0.0.1:88;
  13.                         include proxy.conf;
  14.                         }

  15.                 location ~ .*\.(php|php5)?$
  16.                         {
  17.                                 proxy_pass http://127.0.0.1:88;
  18.                                 include proxy.conf;
  19.                         }

  20.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.                         {
  22.                                 expires      30d;
  23.                         }

  24.                 location ~ .*\.(js|css)?$
  25.                         {
  26.                                 expires      12h;
  27.                         }

  28.                 access_log off;
  29.         }



  30. server
  31.         {
  32.                 listen       80;
  33.                 server_name *.abc.com;
  34.                 index index.html index.htm index.php default.html default.htm default.php;
  35.                 root  /home/wwwroot/abc/company;

  36.                 location / {
  37.                         try_files $uri @apache;
  38.                         }

  39.                 location @apache {
  40.                         internal;
  41.                         proxy_pass http://127.0.0.1:88;
  42.                         include proxy.conf;
  43.                         }

  44.                 location ~ .*\.(php|php5)?$
  45.                         {
  46.                                 proxy_pass http://127.0.0.1:88;
  47.                                 include proxy.conf;
  48.                         }

  49.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  50.                         {
  51.                                 expires      30d;
  52.                         }

  53.                 location ~ .*\.(js|css)?$
  54.                         {
  55.                                 expires      12h;
  56.                         }

  57.                 access_log off;
  58.         }
复制代码

论坛也已经帮定到一级目录

[ 本帖最后由 dm168 于 2011-7-27 13:14 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-7-27 15:11:00 | 显示全部楼层


dd.abc.com 单独添加一个
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2011-7-27 16:57:38 | 显示全部楼层

dd.668ph.com本来就是单独添加的,但无法转到论坛,还有就是*.668ph.com无法单独添加,用/root/vhost.sh单独添加*.668ph.com显示是成功,但找不到*.668ph.com.conf 如果删除*.668ph.com就会连其它的二级域名一起删除 这是bug吗?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-7-27 17:27:09 | 显示全部楼层



这个不是bug,因为* 在Linux下就是通配符,*之类的需要单独修改配置文件不能通过/root/vhost.sh 添加
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2011-7-27 18:02:39 | 显示全部楼层

上面的泛解析问题我在apach做了设置,还需要在nignx做设置吗?还是只要在其中一个做设置就可以了啊?

军哥运维代购:http://shop63846532.taobao.com/

发表于 2011-7-27 19:45:14 | 显示全部楼层

nginx、apache都是需要加才会起作用的。
 楼主| 发表于 2011-7-27 20:10:32 | 显示全部楼层

谢谢军哥,如果能实现只加一个规则就能搞定就好了,现在我加nignx规则就打不开,可能是规则有问题。再次谢谢军哥
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2011-7-27 21:06:37 | 显示全部楼层

问题的原因找到了,是伪静态规则的问题,在lnmpa中应该用apach还是nginx的伪静态规则呢?还是要重新写一个新的规则呢?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2011-7-28 01:09:08 | 显示全部楼层

rewrite 其实在NGINX里面加也是可以的。

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2011-7-28 11:02:42 | 显示全部楼层



rewrite 只在在 apach或nginx其中一个加就可以了是吧,不用两个都加吧?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-21 00:34 , Processed in 0.029102 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表