<VirtualHost *:80 *:81>
ServerAdmin [email protected]
DocumentRoot /active/www/yingchao123/trade
ServerName trade.test.yingchao123.com
ServerAlias trade.yingchao123.com
RewriteEngine On
RewriteRule ^([\da-z]{1,10})$ ./index.php?mod=list&do=unique&alias=$1 [L]
RewriteRule ^([\da-z]{1,10})&(.+)$ ./index.php?mod=list&do=unique&alias=$1&$2 [L]
</VirtualHost>
但这样写会出现 出现 400 Bad Request 错误
解决方法是将rewrite规则写倒directory中:
<VirtualHost *:80 *:81>
ServerAdmin [email protected]
DocumentRoot /active/www/yingchao123/trade
ServerName trade.test.yingchao123.com
ServerAlias trade.yingchao123.com
<Directory "/active/www/yingchao123/trade">
RewriteEngine On
RewriteRule ^([\da-z]{1,10})$ ./index.php?mod=list&do=unique&alias=$1 [L]
RewriteRule ^([\da-z]{1,10})&(.+)$ ./index.php?mod=list&do=unique&alias=$1&$2 [L]
</Directory>
</VirtualHost>
重启Apache,问题解决
说明:apache检查配置是否语法错误httpd.exe -t 或者apachectl -t,nginx对应的命令是nginx -t
原文地址:https://www.cnblogs.com/hnhycnlc888/p/9527667.html