【问题标题】:Apache 2.4 ProxyPassMatch Redirect 301 issueApache 2.4 ProxyPassMatch 重定向 301 问题
【发布时间】:2018-06-02 11:51:59
【问题描述】:

virtualhost 或 .htaccess 中的重定向 301 不适用于 php 文件。

我的环境: 阿帕奇 2.4 php-fpm 7.0

我的虚拟主机配置:

<VirtualHost *:80>
    ServerAdmin xxx@example.com
    DocumentRoot /pathto/www/
    DirectoryIndex index.htm index.php index.html
    ServerName www.example.com

    <Directory "/pathto/www/">
        RewriteEngine on
        Redirect 301 /myfile.php "http://www.example.com/page"
        Redirect 301 /contact "http://www.example.com/contacts.htm"

        Include /pathto/www/.htaccess
    </Directory>

    ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.0-fpm.sock|fcgi://localhost/pathto/www/
</VirtualHost>

Redirect 301 /file.php 也在 .htaccess 中,但没有人在工作。 所有其他基于 uri 或别名的重定向规则都可以正常工作!?

帮助欣赏。

【问题讨论】:

    标签: php apache redirect


    【解决方案1】:

    发现问题。重定向301使用mod_alias而不是mod_rewrite,php文件直接被代理匹配处理。 解决方法是用 Rewriterule 重写重定向,让 mod_rewrite 像这样处理。

    RewriteRule ^/myfile.php "http://www.example.com/page" [L,R=301]
    

    希望有帮助

    【讨论】:

      猜你喜欢
      • 2011-08-02
      • 2011-06-12
      • 2019-04-04
      • 2010-11-07
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2014-03-10
      • 2011-11-01
      相关资源
      最近更新 更多