如何设置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
阅读(1119) | 评论(1) | 转发(0) |