简体   繁体   English

.htaccess拇指php图像链接

[英].htaccess thumb php image link

I want to make better links to thumb image with php 我想用php更好地链接到拇指图像

my current image link to thumb 我当前的图像链接到拇指

mydomain.tld/thumbimg/thumb.php?size=50x50&src=../data/filename.jpg mydomain.tld / thumbimg / thumb.php?size = 50x50&src = .. / data / filename.jpg

but I want in this form 但我想要这种形式

mydomain.tld/thumbimg/50x50/filename.jpg mydomain.tld / thumbimg / 50x50 / filename.jpg

I tried with this htaccess code 我尝试使用此htaccess代码

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+|)/?$ thumb.php?size=$1&src=../data/$2
# Handle requests for "thumb.php"

Where the error and how to fix it? 错误在哪里以及如何解决?

UPDATE: I found the solution, this is code 更新:我找到了解决方案,这是代码

RewriteEngine On
RewriteRule ^(.*)$ -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)/([^/.]+)\.jpg$ thumb.php?size=$1&src=../data/$2.jpg [L]
RewriteRule ^([^/.]+)/([^/.]+)\.png$ thumb.php?size=$1&src=../data/$2.png [L]

Try below rule in your respective directory, 在您各自的目录中尝试以下规则,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w-]+)/([\w-]+)\.jpg$ thumb.php?size=$1&src=../data/$2 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM