2017-08-14 211 views
0

下面是我的.htaccess代码:阿帕奇重写规则无法正常运行

<VirtualHost *:80> 
     ServerName api.xxxx.com 
     DocumentRoot /dianxiaoer/html/two-twenty 
     <Directory /dianxiaoer/html/two-twenty> 
       RewriteEngine on 
       RewriteCond %{REQUEST_FILENAME} !-f 
       RewriteCond %{REQUEST_FILENAME} !-d 
       RewriteRule . index.php 
       RewriteRule /notify/alipay /mobile/index.php?act=notify&op=alipay 
       #Options Indexes FollowSymLinks MultiViews 
       Options FollowSymLinks 
       AllowOverride None 
       Require all granted 
       Order allow,deny 
       allow from all 
     </Directory> 
</VirtualHost> 

URL重写规则

api.xxxx.com/notify/alipay to api.xxxx.com/mobile/index.php?act=notify&op=alipay 

无法正常工作。任何人都可以请解释我在这里做错了什么?谢谢。

+1

你有什么错误? – CUGreen

+0

代码的第九行不起作用,无法重定向 – uzaiHu

+0

可能是因为第8行的规则覆盖了它 – CUGreen

回答

0

此行RewriteRule . index.php将覆盖它后面的任何内容。

如果你把那个放在最后,它应该解决你的问题。

试换8号线和9这样的:

<VirtualHost *:80> 
     ServerName api.xxxx.com 
     DocumentRoot /dianxiaoer/html/two-twenty 
     <Directory /dianxiaoer/html/two-twenty> 
       RewriteEngine on 
       RewriteCond %{REQUEST_FILENAME} !-f 
       RewriteCond %{REQUEST_FILENAME} !-d 
       RewriteRule /notify/alipay /mobile/index.php?act=notify&op=alipay [L] 
       RewriteRule . index.php 
       #Options Indexes FollowSymLinks MultiViews 
       Options FollowSymLinks 
       AllowOverride None 
       Require all granted 
       Order allow,deny 
       allow from all 
     </Directory> 
</VirtualHost> 

希望可以解决您的问题。