2017-07-25 53 views

回答

0

我想你想在新的URL文件名的時候呢? (不僅是 「.JPG」)

RewriteRule ([^/]+\.jpg)$ http://mysite.00xxxtapp.com/folder1/$1 [R=301,L]

RewriteRule ([^/]+\.jpg)$ /folder1/$1 [L]

,如果你想繼續舊的URL

編輯

所以你需要超過1重寫規則。

我建議的步驟

  1. 所有的「假」的URL重定向到一些PHP腳本
  2. 所有圖像/文件夾1 /必須重定向或進行inaccessable(建議:把它們放在文檔根目錄外| )

RewriteEngine On # all images in somefolder will be parsed through a php script RewriteRule somefolder/([^/]+\.jpg)$ /imageshower.php [L]
# redirect to a no access image

RewriteRule folder/*\.jpg /no-access.jpg [R]

php腳本將能夠做一些檢查,如'是用戶登錄?'或者他是否我試圖文件。如果用戶試圖通過在地址直接寫入的網址(www.xyz.com/abc/image.jpg)訪問圖像,以保護我的圖片權利

<?php 
    $filename = basename($_SERVER['REQUEST_URI']); // this still points to the jpg 
    if(is_file('folder/'. $filename) && is_allowed($user, $filename)) { 

    header('Content-Type: images/jpg'); // or other like .gif or .pdf etc 
    readfile('folder/'. $filename); 
    } 
?> 
+0

我需要將瀏覽器重定向到其他頁面。 –

+0

增加了一些更多的答案 –

相關問題