Menu

#13 Support for 301 Redirects

open
nobody
None
5
2012-12-06
2012-03-04
Big T
No

phpThumb has support for 302 redirects. This was added in v1.7.5 and improved in v1.7.8.

I would like to request support for 301 redirects.

I was able to add this myself by changing line 747 in phpthumb.functions.php from this:

if (preg_match('#302 [a-z ]+; Location\\: (http.*)#i', $errstr, $matches)) {

to this:

if ((preg_match('#302 [a-z ]+; Location\\: (http.*)#i', $errstr, $matches)) || (preg_match('#301 [a-z ]+; Location\\: (http.*)#i', $errstr, $matches))) {

The other addition I would recommend is a change in line 217 of phpThumb.config.php to further explain support for redirects:

From this:

$PHPTHUMB_CONFIG['http_follow_redirect'] = true; // if true (default), follow "302 Found" redirects to new URL; if false, return error message

to this:

$PHPTHUMB_CONFIG['http_follow_redirect'] = true; // if true (default), follow "302 Found" or "301 Found" redirects to new URL; if false, return error message

Clearly there are other ways to implement this, and that's all up for debate. This is how I made it work on the system I was working on, and it was relatively easy and transparent.

Thanks for all your work on this project.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.