Apache-重写
1. 开启url重写模块
vim /usr/local/apache/etc/httpd.conf
去掉前面的#
#LoadModule rewrite_module modules/mod_rewrite.so
2. 找到对应域名的配置文件,让.htaccess文件生效
vim /usr/local/apache/etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin XXXX@163.com
DocumentRoot "/usr/local/apache/htdocs/XXX"
ServerName www.XXXX.com
ServerAlias XXXX.com
ErrorLog "logs/XXX.com-error_log"
CustomLog "logs/XXX.com-access_log" common
<Directory "/usr/local/apache//htdocs/XXX">
Options FollowSymLinks
//AllowOverride的值设置成All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
3. 在/usr/local/apache/htdocs/XXX创建一个.htaccess文件
cd /usr/local/apache/htdocs/XXX/
touch .htaccess
vim .htaccess
开启重写引擎
RewriteEngine on
重写规则
RewriteRule (\d+).html a.php
4. 重启apache
apachectl restart