【问题标题】:Timthumb htaccess rewriteTimthumb htaccess 重写
【发布时间】:2013-08-06 18:44:57
【问题描述】:

因为一天,我的 timthumb 停止工作了

但确实发现它可能与 modsecurity 有关。

以下,直到一天前才起作用。

http://www.HOST.com/wp-content/themes/THEME/scripts/timthumb.php?src=http://www.HOST.com/wp-content/uploads/2013/05/image.jpg&w=70&h=50&zc=1&q=100

现在只能使用

http://www.HOST.com/wp-content/themes/THEME/scripts/timthumb.php?src=/wp-content/uploads/2013/05/image.jpg&w=70&h=50&zc=1&q=100

尝试将其放入我的 htaccess 中,但没有任何变化

# WPhtc: Begin Custom htaccess
RewriteCond %{REQUEST_URI} !^/(timthumb) [NC]
RewriteRule ^scripts/timthumb.php?src=/(.*)x(.*)/r/(.*) scripts/timthumb.php?src=http://www.HOST.com/$3&h=$2&w=$1&c=1
# WPhtc: End Custom htaccess

【问题讨论】:

  • 通过 HOSTGATOR 解决,MODSECURITY 中的白名单域!,$thumbnail = parse_url($src, PHP_URL_PATH); 将是另一个选项,不使用 htaccess

标签: .htaccess timthumb


【解决方案1】:

将 TimThumb 用于您的图像,可能会导致一些.. 看起来凌乱(以免面对它,无法实现)的代码。观察..

<img alt="Camping" src="/timthumb.php?src=/images/feb/image_001.jpg&amp;w=250&amp;h=250&amp;" />

为什么不消除混乱并使用一些时髦的 .htaccess 重定向?

<img alt="Camping" src="/images/feb/250/image_001.jpg" />

是不是看起来好多了?现在,您的精彩露营图像宽度设置为 250 像素,高度保持在正确的比例。

TimThumb htaccess 重写 实现这一点非常容易和简单!更新您的 .htaccess 文件,就像这样。

# With your other RewriteCond rules
RewriteCond %{REQUEST_URI} !^/(images) [NC]
RewriteRule ^(.+)/$ /$1 [R,L]

# Width
RewriteRule ^images/([a-zA-Z0-9-]+)/([0-9]+)/([a-z0-9.]+)?$ /tt.php?src=/images/$1/$3&amp;w=$2

如果您没有任何类型的文件夹系统,并且您的所有图像都只是放入图像文件夹中,您可以使用以下内容

RewriteRule ^images/([0-9]+)/([a-z0-9.]+)?$ /tt.php?src=/images/$2&amp;w=$1

Source

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-28
  • 2010-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多