php - htaccess:将 .png 重定向到 .php 页面并显示 html
php - htaccess: redirect .png to .php page and display html
我在根目录中有一个名为 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
它 returns 404
您可以在/picture/.htaccess
中使用此规则
RewriteEngine On
RewriteBase /picture/
RewriteRule \.png$ index.php [L,NC]
我在根目录中有一个名为 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
它 returns 404
您可以在/picture/.htaccess
RewriteEngine On
RewriteBase /picture/
RewriteRule \.png$ index.php [L,NC]