44965455 534be470f2 URLリダイレクタ

2chで、外部サイトへのURLリンクで使っているime.nuサービスみたいなのを書いてみた。

使い方
http://matsu.teraren.com/link/www.yahoo.co.jp
http://matsu.teraren.com/link/http://www.yahoo.co.jp

リンク元をさらしたくないときにはどうぞ。

ソースコード

index.php

<?php
// path prefix
$prefix = '/~matsu/link/';

$url = substr($_SERVER["REQUEST_URI"], strlen($prefix));
// add protocol if protocol is not specified
if(strpos($url, 'http') === false){
  $url = 'http://'.$url;
}

$url = htmlspecialchars($url);

?>
<html>
<head>
<title>jump</title>
</head>
<body>

<a href="<?php print $url; ?>"><?php print $url; ?></a><br />
別のサイトにジャンプしようとしています。宜しければ上記のリンクをクリックしてください
</p>
</body>
</html>

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~matsu/link/index.php [L]
</IfModule>
hatena URLリダイレクタ
 URLリダイレクタ
article clipper URLリダイレクタ
btn logo 16 URLリダイレクタ