【问题标题】:php - htaccess: redirect .png to .php page and display htmlphp - htaccess:将 .png 重定向到 .php 页面并显示 html
【发布时间】:2015-10-22 09:31:28
【问题描述】:

我在根目录中有一个名为 picture 的文件夹,我想将所有 .png 网址重定向(仅适用于该文件夹)到:

/picture/index.php

显示 index.php html 内容。我的意思是重定向网址,例如:

/picture.png/picture/whatever.png

其实这是我图片文件夹里面的.htaccess文件:

RewriteEngine On
RewriteRule ^/picture/(\w+)\.png$ /picture/index.php [L]

但如果我转到domain.com/picture.png,它会返回 404

【问题讨论】:

  • 我对htaccess和php不是很熟悉,希望简单:)

标签: php .htaccess mod-rewrite redirect png


【解决方案1】:

您可以在 /picture/.htaccess

中使用此规则
RewriteEngine On
RewriteBase /picture/

RewriteRule \.png$ index.php [L,NC]

【讨论】:

    猜你喜欢
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 2022-01-19
    • 1970-01-01
    • 2013-03-26
    • 2015-10-22
    • 2016-10-29
    相关资源
    最近更新 更多