Apache 重定向

apache的AllowOverride以及Options使用详解

    通常利用Apache的rewrite模块对 URL 进行重写的时候, rewrite规则会写在 .htaccess 文件里。但要使 apache 能够正常的读取.htaccess 文件的内容,就必须对.htaccess 所在目录进行配置。
    AllowOverride参数就是指明Apache服务器是否去找.htacess文件作为配置文件,如果设置为none,那么服务器将忽略.htacess文件,如果设置为All,那么所有在.htaccess文件里有的指令都将被重写。对于AllowOverride,还可以对它指定如下一些能被重写的指令类型。


不允许重写:
通常利用Apache的rewrite模块对 URL 进行重写的时候, rewrite规则会写在 .htaccess 文件里。但要使 apache 能够正常的读取.htaccess 文件的内容,就必须对.htaccess 所在目录进行配置。从安全性考虑,根目录的AllowOverride属性一般都配置成不允许任何Override ,即 

<Directory /> 
        AllowOverride None
</Directory>

允许重写:
    在要支持url rewirte的目录启用 Options FollowSymLinks和AllowOverride All 

Alias /php "E:/project_self/joomla_self/"
<Directory "E:/project_self/joomla_self/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>


实例:

    1、windows下配置apache重定向:

    apache 配置文件:Apache/Config/httpd.conf  

# Deny access to the entirety of your server's filesystem. You must 
# explicitly permit access to web content directories in other 
# <Directory> blocks below. 

<Directory /> 
AllowOverride All 
Require all granted 
</Directory> 

2、linux下配置apache重定向:
apache配置文件:Apache2/sites-available/000-default.conf
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html 
Alias /j /var/www/joomla 
<Directory /var/www/joomla> 
Options FollowSymLinks MultiViews
AllowOverride All
</Directory> 








    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值