Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15366422
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2010-03-08 12:26:49

如何设置apache2的URL重写

luther@gliethttp:~$ sudo service apache2 restart
 * Restarting web server apache2                                                                    Syntax error on line 2 of /etc/apache2/httpd.conf:
Invalid command 'ReWriteRule', perhaps misspelled or defined by a module not included in the server configuration

luther@gliethttp:~$ sudo vim /etc/apache2/httpd.conf
ServerName localhost
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         [L,R]
luther@gliethttp:~$ sudo service apache2 restart
luther@gliethttp:~$ firefox

或者
可以在apache2上直接设置
luther@gliethttp:~$ sudo vim /etc/apache2/httpd.conf
ServerName localhost
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
RewriteEngine on
# 表示当没有输入子目录的情况下使用trac/作为默认访问目录,当然设置完成之后apache restart,同时firefox也需要清空全部Clear Recent history;这样apache设置的效果才能在firefox上体现出来
RedirectMatch ^/$
或者
RedirectMatch ^/$ /trac/  这样输入127.0.0.1时,会自动连接到127.0.0.1/trac/

luther@gliethttp:~$ vim auto.html




luther@gliethttp:~$ firefox auto.html

阅读(1085) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~