• MAC OSX 10.10 下启用自带的Apache的rewrite模块


    1.修改Apache配置文件

    sudo vim /etc/apache2/httpd.conf

    LoadModule rewrite_module libexec/apache2/mod_rewrite.so  去掉该行前面的#

    注释掉 #Require all denied,

    增加一行  Require all granted

    # 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 />
         #Options Indexes MultiViews
         Require all granted
        AllowOverride none
       # Require all denied
    </Directory>

    2. vim/etc/apache2/extra/httpd-vhosts.conf

    增加 VirtualHost,并且将 Directory的配置写好,如下的配置

    <VirtualHost *:80>
        DocumentRoot "/Users/caoxin/wwwroot/xxx/movie_platform/public"
        ServerName api.movie.com
        <Directory "/Users/caoxin/wwwroot/xxx/movie_platform/public">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        </Directory>
        ErrorLog "/private/var/log/apache2/api_movie-error_log"
        CustomLog "/private/var/log/apache2/api_movie-access_log" common
    </VirtualHost>

    3. 修改本机的host设置 (vim /etc/hosts)

    127.0.0.1   xxx.com

    4. 重启apache   

    sudo apachectl restart

    ps -ef |grep httpd

    5.测试rewrite的功能

    在网站的根路径下,创建.htaccess文件,将该文件的权限设置为777

    sudo chmod 777 .htaccess

    以下为.htaccess测试实例:

    # BEGIN
    <IfModule mod_rewrite.c>
    RewriteEngine  on
    RewriteBase /
    RewriteRule .*$ http://www.baidu.com
    </IfModule>
    #END

    测试方法: 访问网站任何路径页面,均会跳转到本博客,说明Rewrite已生效。

    提醒:正常修改.htaccess一般都是即时生效,如果修改的是apache conf配置文件,一般需要重启apache一次。

  • 相关阅读:
    设置共享文件夹大小
    About IConfigurationSectionHandler Interface
    zoj 1050
    SQL Server 数据库优化经验总结
    一、页面输出缓存
    [转]深入解读 ADO.NET 2.0 的十大最新特性
    ASP.NET 缓存学习
    [转]写给ASP.NET程序员:网站中的安全问题
    [转] ASP.NET 性能提升秘诀之管道与进程优化
    实战 SQL Server 2005 镜像配置
  • 原文地址:https://www.cnblogs.com/mingaixin/p/5279040.html
Copyright © 2020-2023  润新知