【发布时间】:2015-11-12 23:30:01
【问题描述】:
我目前正在压缩图像时生成查询字符串 URL。
例如example.com/img.php?compressed=image.jpg&w=280
但我需要生成静态 URL 路径。
例如example.com/img/image.jpg/width_280
我正在使用以下代码来构造查询字符串 URL:
require_once 'img.class.php';
$getImage = new GetImage();
$getImage->setCacheFolder(FOLDER_CACHE);
$getImage->setErrorImagePath(FILEPATH_IMAGE_NOT_FOUND);
$getImage->setJpegQuality(JPEG_QUALITY);
$img = $_GET["img"];
$width = -1;
$width = isset($_GET["w"])?$_GET["w"]:-1;
$height = isset($_GET["h"])?$_GET["h"]:-1;
$type = "";
if(isset($_GET["exact"])) $type = GetImage::TYPE_EXACT;
else if(isset($_GET["exacttop"])) $type = GetImage::TYPE_EXACT_TOP;
$getImage->showImage($img,$width,$height,$type);
是否可以通过任何方式更改此代码以生成静态 URL?
它必须是硬编码的,而不是 mod_rewrite 解决方案。
非常感谢!
B.
【问题讨论】:
-
静态网址是什么意思?
-
对不起,我的意思是没有 QS 的 URL 路径。例如example.com/img/image.jpg/width_280
-
我不相信如果不使用 mod_rewrite 这将是可能的
-
你可以试试 example.com/img.php/width_20/image.jpg - 查看 $_SERVER 获取有问题的 url
标签: php url query-string