htaccess 重定向 403 将文件夹添加到路径(如果未找到)



我有这个网址 - 正在工作

http://pic.site.com/images/nofeymata/102.jpg

我的应用程序中有这个网址 - 我收到 403 错误

http://pic.site.com/nofeymata/102.jpg 

只有当我得到 403 eroor 时,我才需要一种方法images"添加"到路径中

我的 htAccess 锁是这样的:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^width=d+&height=d+&image=(.*)
RewriteRule ^ %1? 
RewriteEngine On
RewriteCond %{THE_REQUEST} imageget.php [NC]
RewriteRule ^ - [NC,L]
#disallow access to other php files
RewriteCond %{THE_REQUEST} .+.php [NC]
RewriteRule ^ - [F,L]

所以当我的应用程序搜索这个网址时

http://pic.site.com/nofeymata/102.jpg 

并得到 403 威尔·雷德里克特

http://pic.site.com/images/nofeymata/102.jpg 

这部分/nofeymata/102.jpg随机可以是任何文件夹和文件

我试过了

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/images[NC]
RewriteRule ^ /images%{REQUEST_URI} [R=403,L]

这是有效的,但是当我查询这个

http://pic.site.com/images/nofeymata/102.jpg

我得到

http://pic.site.com/images/images/nofeymata/102.jpg

我不能把它弄出来,谢谢!

我添加这个

ErrorDocument 403 /403.php

并在 404.php 文件中

<?php
$url = $_SERVER["REQUEST_URI"];
$http = $_SERVER["SERVER_NAME"]."/images".$url ;
header("Location: http://".$http); /* Redirect browser */
?>

和它的工作现在完美的良好润滑

最新更新