日期:2014-05-16  浏览次数:20815 次

Apache虚拟主机配置及WordPress固定连接设置

一.虚拟主机配置

首先去除httpd.conf文件下默认的DocumentRoot和<Directory "XXX">配置,添加类似以下代码。

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

NameVirtualHost 127.0.0.1:81

<VirtualHost school.ruanko.com:81>
	ServerAdmin school.ruanko.com
	ServerName school.ruanko.com
	ServerAlias school.ruanko.com
	ErrorLog "logs/wplatest.com-error.log"
	CustomLog "logs/wplatest.com-access.log" combined
	DocumentRoot "F:/works/php/school"
	<Directory "F:/works/php/school">
	    Options Indexes FollowSymLinks
	    AllowOverride all
	    Order allow,deny
	    Allow from all
	</Directory>
</VirtualHost>

<VirtualHost note.dreamworker.org:81>
	ServerAdmin note.dreamworker.org
	ServerName note.dreamworker.org
	ServerAlias note.dreamworker.org
	ErrorLog "logs/wpstable.com-error.log"
	CustomLog "logs/wpstable.com-access.log" combined
	DocumentRoot "F:/works/php/note"
	<Directory "F:/works/php/note">
	    Options Indexes FollowSymLinks
	    AllowOverride all
	    Order allow,deny
	    Allow from all
	</Directory>
</VirtualHost>
?

二.固定链接配置

首先要在WordPress中设置固定链接的样式,再来修改Apache的配置以支持URL重写。

修改httpd.conf文件,去除LoadModule rewrite_module modules/mod_rewrite.so前面的注释。然后记得吧<Directory>标签内的AllowOverride属性设置为All(本文前面的代码已经设置过了)。

?