文章目录
- 如https://wx1.sina.com/psc?/xxxxxxxxx.jpg
- <?php if(!empty($_GET['s'])){ $url='https://wx1.sina.com/psc?'.$_GET['s']; }else{ $url='404.JPG';//没有参数时显示默认图片 } header("Location:".$url); ?>
- 将imgs.php上传到根目录,然后打开https://域名/imgs.php?s=xxxxxxxxx.jpg,如果能打开就成功了一半
- 样的链接为动态,不利于搜索引擎的抓取和优化。我们可以利用web释义引擎来重写成静态URL。 nginx引擎写法;编辑所属站点nginx.conf文件 rewrite "imgs/(.+)$" /imgs.php?s=$1; apache引擎写法;编辑所属站点.htaccess文件 RewriteRule imgs/(.+)$ img/imgs?id=$1 [L,NC]
- 保存引擎的配置文件并重启服务后,以以下的链接形式插入到 网站中 https://域名/imgs/xxxxxxxxx.jpg (adsbygoogle = window.adsbygoogle || []).push({});
很多小站点,目前图片的储存用的都是图床,最火的应该就是新浪图床了,但是使用图床,就得面对一个不得不解决的问题了,外链的图片对SEO影响比较大,因此最好将外链转为内链的形式将图片插入到网站里,方法也很简单,只需要新建一个php和配置网站nginx和apache的配置文件。
如https://wx1.sina.com/psc?/xxxxxxxxx.jpg
如https://wx1.sina.com/psc?/xxxxxxxxx.jpg
<?php
if(!empty($_GET['s'])){
$url='https://wx1.sina.com/psc?'.$_GET['s'];
}else{
$url='404.JPG';//没有参数时显示默认图片
}
header("Location:".$url);
?>
将imgs.php上传到根目录,然后打开https://域名/imgs.php?s=xxxxxxxxx.jpg,如果能打开就成功了一半
样的链接为动态,不利于搜索引擎的抓取和优化。我们可以利用web释义引擎来重写成静态URL。
nginx引擎写法;编辑所属站点nginx.conf文件
rewrite "imgs/(.+)$" /imgs.php?s=$1;
apache引擎写法;编辑所属站点.htaccess文件
RewriteRule imgs/(.+)$ img/imgs?id=$1 [L,NC]
保存引擎的配置文件并重启服务后,以以下的链接形式插入到 网站中
https://域名/imgs/xxxxxxxxx.jpg





暂无评论