Apache服务器支持.htaccess和rewrite和virtualhost

Apache服务器支持.htaccess和rewrite和virtualhost
 
最近想升级维护Creke ACG,但是以前自己配置的AMP有些功能不支持,所以要自己动手让他支持。

支持.htaccess
  如何让自己的本地APACHE服务器支持".htaccess"呢?其实只要简单修改一下apache的httpd.conf设置

就可以让APACHE支持.htaccess了,来看看操作

  打开httpd.conf文件(在那里? APACHE目录的CONF目录里面),用文本编辑器打开后,查找

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

  改为

<Directory />
  Options FollowSymLinks
  AllowOverride All
</Directory>

  就可以了

支持rewrite:
LoadModule rewrite_module modules/mod_rewrite.so

支持virtualhost:
在文件末尾加上
include "conf/vhost.conf"
然后在httpd.conf新建一个vhost.conf文件。在该配置文件写上虚拟主机的配置就行。
#NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin [email protected]
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#/VirtualHost>
比如我,就是:

NameVirtualHost *

<VirtualHost *> #默认情况
    DocumentRoot "w:/www"
</VirtualHost>

<VirtualHost *> #Creke ACG站点
    DocumentRoot "w:/www/creke_acg"
    ServerName acg.creke.net
</VirtualHost>

虽然说的是“NOTE: NameVirtualHost cannot be used without a port specifier”,但我仍然这样子配

置成功没有报错,也没有警告。而且可以继续使用80和21500两个端口来访问网站。看来有空要研究一下

http://httpd.apache.org/docs/2.2/vhosts/,看看是否新版本中有和旧版本不同的说明了。

这样,再把本地的host文件暂时添加acg.creke.net为127.0.0.1,就可以在本地调试升级Creke ACG了。

Leave a comment