下面是启用mod_rewrite模块的方法。
第一种方式:
sudo a2enmod rewrite
第二种方式:
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
不管使用哪种方法,都是在 /etc/apache2/mods-enabled 这个目录下面建立了一个链接,只要重启服务器之后就可以生效。 当然要使rewrite生效,还需要修改额外的配置:
sudo vim /etc/apache2/sites-enabled/000-default
将其中的 AllowOverride None 修改为 AllowOverride All,然后重启服务器即可。
sudo /etc/init.d/apache2 restart
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/crmebAdmin/
ServerName mgj.zhijianmeigu.com
<Directory "/var/www/html/crmebAdmin/">
Order allow,deny
Allow from all
AllowOverride All
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>