私のサーバーでは、画像のサイズを変更するためのプラグインとして TimThumb を使用しています。メールのコンテンツ内で使用しようとする場合を除いて、うまく機能します。
Google Gmail はこれhttps://example.com/thumb.php?sr+c=
をsrc
属性として出力します (プラス記号に注意してください)。
ここで、クエリが原因であると読みました。
では、どうすれば.htaccess
自分の URL を書き換えて で削除/thumb.php?src=
でき/src/
ますか?
画像へのリンクは次のようになります。
https://example.com/thumb.php?src=example.jpg
これは私が必要なものです
https://example.com/src/example.jpg
これが私の現在です.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^welcome/([^/]+)/?$ index.php?a=welcome&filter=$1 [NC,QSA,L]
RewriteRule ^explore/([^/]+)/?$ index.php?a=explore&filter=$1 [NC,QSA,L]
RewriteRule ^page/([^/]+)/?$ index.php?a=page&filter=$1 [NC,QSA,L]
RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L,QSA]
index.php
両方ともthumb.php
ルートフォルダーにあります
アップデート
この行を my .htaccess
and visitに追加しようとしましhttps://example.com/src/example.jpg
たが、やはり機能しません。この場合、「ようこそ」ページにリダイレクトされます。
RewriteRule ^src/([^/]*)$ /thumb.php?src=$1 [L]
2回目の更新
私もこれを試しました:
RewriteRule ^src/([^/]+)/?$ thumb.php?src=$1 [NC,QSA,L]
繰り返しますhttps://example.com/src/example.jpg
が、「ようこそ」ページへのリダイレクトが機能していません。
これが私の.htaccessの外観です
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^welcome/([^/]+)/?$ index.php?a=welcome&filter=$1 [NC,QSA,L]
RewriteRule ^explore/([^/]+)/?$ index.php?a=explore&filter=$1 [NC,QSA,L]
RewriteRule ^page/([^/]+)/?$ index.php?a=page&filter=$1 [NC,QSA,L]
RewriteRule ^src/([^/]+)/?$ thumb.php?src=$1 [NC,QSA,L]
RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L,QSA]
3回目の更新
この中thumb.php
に、srcクエリを作成する方法があります
$_GET['src'] = 'https://s3-eu-west-1.amazonaws.com/bucket1'.'/'.$_GET['src'];
ここで何が問題なのかわかりません。
4回目の更新
Vladimir Cveticの回答に基づいて、これを試しました:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^src/(.*)$ /thumb.php?src=$1 [L,QSA]
RewriteRule ^welcome/([^/]+)/?$ index.php?a=welcome&filter=$1 [NC,QSA,L]
RewriteRule ^explore/([^/]+)/?$ index.php?a=explore&filter=$1 [NC,QSA,L]
RewriteRule ^page/([^/]+)/?$ index.php?a=page&filter=$1 [NC,QSA,L]
RewriteRule ^src/([^/]+)/?$ thumb.php?src=$1 [NC,QSA,L]
RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L,QSA]
そして再びそれは機能していません、これはエラーです:
`The 't' parameter is not set.`
しかし、次のように「t」パラメーター条件を空に設定したので、奇妙です。
if(!empty($_GET['t'])) {
if($_GET['t'] == 'a') {
$type = 'uploads/avatars';
$width_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
$height_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
} elseif($_GET['t'] == 'b') {
$type = 'uploads/backgrounds';
...
} else {
exit('Invalid parameter value');
}
} else {
$_GET['t'] == 'a';
$type = 'uploads/avatars';
$width_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
$height_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
}
実際にアクセスするhttps://example.com/thumb.php?src=example.jpg
と、アバター画像が正しく表示されます