htaccess重写直接照片链接

时间:2014-06-22 13:27:02

标签: apache .htaccess mod-rewrite redirect rewrite

我有直接的照片链接:http://upload.domain.com/image-upload/date/original-generated_name.jpg 它是上传照片信息的直接链接。 这个直接链接胸围重定向到:http://upload.domain.com/view/genarated_name.jpg到我现在的htacces(没有任何重定向选项)。

# BEGIN Scripteen FREE Image Hosting Script
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# general catch-all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1&%{QUERY_STRING} [L]

</IfModule>
# END

您对如何做到这一点有什么建议吗?

1 个答案:

答案 0 :(得分:0)

将此规则放在根.htaccess文件中:

RewriteEngine On

RewriteRule ^image\.uploads/[^/]+/original-(.+)$ /view-image/$1 [NC,L,R=302]

# general catch-all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [L,QSA]