访问 http://loveke.com ,则跳转到 http://www.loveke.com。
首先开启rewrite模块。去掉注释(#)
#LoadModule rewrite_module modules/mod_rewrite.so
- 配置Apache 配置文件 httpd-vhosts.conf
- <VirtualHost *:80>
DocumentRoot “E:/Web/xxxhome”
ServerName www.loveke.com
ServerAlias loveke.com
ErrorLog “|bin/rotatelogs.exe logs/home-error-%y-%m-%d-%H_%M_%S.log 20M”
CustomLog “|bin/rotatelogs.exe logs/home-access-%y-%m-%d-%H_%M_%S.log 20M” common
<Directory “E:/Web/xxxhome”>
Options Indexes FollowSymLinks
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
- <VirtualHost *:80>
- 编写.htaccess
- <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^xobm.com [NC]
RewriteRule ^(.*) http://www.xobm.com/ [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>