繁体   English   中英

apache重写规则无法按预期工作

[英]apache rewrite rule not working as expected

以下是我的.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

无法正常工作。 谁能解释一下我在做什么错? 谢谢。

这行RewriteRule . index.php 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>

希望能解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM