[英]htaccess, If redirected from specific .php file
我有一個 .htaccess 文件無法正常工作。
這是我的 PHP 文件 (access.php)
header("Location: https://example.com/images/flower.jpg");
這就是我的 .htaccess
<FilesMatch "\.(jpe?g|png)$">
RewriteEngine On
RewriteCond "%{HTTP_REFERER}" "!https://example\.com/scripts/access\.php" [NC]
RewriteRule https://%{HTTP_HOST}/management/htaccess/access\.php?%{QUERY_STRING} [R]
</FilesMatch>
我想要完成的事情:如果https://example.com/scripts/access.ZE1BFD762321E409CEE4ZAC0B6E8重定向,我只希望https://example.com/images/flower.jpg能夠工作如果它不是由 access.php 重定向,那么我希望它到 go 回到 access.php。
修復它:
<FilesMatch "\.(jpe?g)$">
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ /scripts/access\.php?%{QUERY_STRING} [L,NC]
RewriteCond %{HTTP_REFERER} !example.com/scripts/access\.php [AND]
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^ /scripts/access\.php?%{QUERY_STRING} [L,NC]
</FilesMatch>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.