‘Apache’ 存档

Windows下让Apache支持rewrite和.htaccess

先查看一下你的phpinfo(),如果在apache2handler的Loaded Modules 中找到了mod_rewrite 那么说明你的rewrite module已经加载了。如果没有开启“mod_rewrite”,则打开您的apache安装目录“/apache/conf/”下的 httpd.conf 文件,通过Ctrl+F查找到“LoadModule rewrite_module”,将前面的”#”号删除即可。如果没有查找到,则到“LoadModule”区域,在最后一行加入“LoadModule rewrite_module modules/mod_rewrite.so”(必选独占一行),然后重启apache服务器即可。

全部设定妥当后,我又进行了一次尝试,咦,为什么WordPress中设置的永久链接还是无效呢?问题在这里:

<Directory “E:/www”>

#

# Possible values for the Options directive are “None”, “All”,

# or any combination of:

# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

#

# Note that “MultiViews” must be named *explicitly* — “Options All”

# doesn’t give it to you.

#

# The Options directive is both complicated and important. Please see

# http://httpd.apache.org/docs/2.2/mod/core.html#options

# for more information.

#

Options Indexes FollowSymLinks

#

# AllowOverride controls what directives may be placed in .htaccess files. # It can be “All”, “None”, or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride All

#

# Controls who can get stuff from this server.

#

Order allow,deny

Allow from all

</Directory>

看到我加粗的那行了吧,AllowOverride指令,决定了你的.htaccess是否生效,如果你在调试永久链接的时候发现不起作用,不一定只是因为mod_rewrite没有加载,还有可能是httpd.conf设置不对造成的哦~~

Apache服务器的二级域名支持

首先,你的拥有一个有泛域名解析的顶级域名,例如: domain.com其次,在 httpd.conf 中打开 mod_rewrite之后,在 httpd.conf 的最后,添加以下内容:

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/usr/local/etc/apache(Unix平台最流行的WEB服务器平台)/vhost.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
(更多…)

Apache 中设置目录别名网站

如果你的服务器对应IP是 192.168.1.2 或者其他,本身已经有一个站点A存在,现在另外设置站点B,站点B的目录不在站点A目录下,也不做虚拟主机,现在做目录别名设置。

在Apache 中设置如下:

Alias /dada/ “/home/dada//”
<Directory “/home/dada/”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

用 http://192.168.1.2/dada/ 即可访问站点B

Win Apache VirtualHost虚拟主机配置

服务器配置

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *

<VirtualHost *>
ServerAdmin abc@abc.com
DocumentRoot “E:/WAMP/Apache/htdocs/”
ServerName abc.com
ServerAlias www.abc.com
DirectoryIndex index.htm
</VirtualHost>

<Directory “E:/WAMP/Apache/htdocs”>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Twitter Delicious Facebook Digg Stumbleupon Favorites 更多
如非标明[原创]的内容均来自互联网,如有侵权请来信告知以便删除。