MAC OSX 10.10 下启用自带的Apache的rewrite模块
2016-03-15 13:02
731 查看
1.修改Apache配置文件
sudo vim /etc/apache2/httpd.conf
LoadModule rewrite_module libexec/apache2/mod_rewrite.so 去掉该行前面的#
注释掉 #Require all denied,
增加一行 Require all granted
2. vim/etc/apache2/extra/httpd-vhosts.conf
增加 VirtualHost,并且将 Directory的配置写好,如下的配置
3. 修改本机的host设置 (vim /etc/hosts)
127.0.0.1 xxx.com
[b]4. 重启apache [/b]
sudo apachectl restart
ps -ef |grep httpd
5.测试rewrite的功能
在网站的根路径下,创建.htaccess文件,将该文件的权限设置为777
sudo chmod 777 .htaccess
以下为.htaccess测试实例:
测试方法: 访问网站任何路径页面,均会跳转到本博客,说明Rewrite已生效。
提醒:正常修改.htaccess一般都是即时生效,如果修改的是apache conf配置文件,一般需要重启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
[b]4. 重启apache [/b]
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一次。
相关文章推荐
- apache的URL重写
- 开源许可证GPL、BSD、MIT、Mozilla、Apache和LGPL的区别
- 采用Apache作为WebLogic Server集群的负载均衡器
- WAMPServer多站点配置
- 查询Apache安装目录遇到的问题
- 安装xampp后apache不能启动解决方法
- Apache的prefork模式和worker模式
- 高性能apache服务器配置大并发教程MPM模块配置
- org.apache.subversion.javahl.ClientException: Unsupported working copy format svn: This client is to
- Apache漏洞修复
- ubuntu apache2配置详解
- Apache中 File does not exist: /var/www/html/favicon.ico
- wamp apache无法启动的解决方法
- Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart
- apache学习笔记
- Site
- windows快速搭建本地apache php mysql开发环境,多站点域名访问
- Apache 不记录指定文件类型的日志――LAMP环境搭建
- Apache 日志切割――LAMP环境搭建
- Apache+svn