138 文字
1 分
URLリダイレクタ

2chで、外部サイトへのURLリンクで使っているime.nuサービスみたいなのを書いてみた。
使い方
https://matsu.teraren.com/link/www.yahoo.co.jp
https://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 specifiedif(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>別のサイトにジャンプしようとしています。宜しければ上記のリンクをクリックしてください</p></body></html>.htaccess
<ifmodule mod_rewrite.c>RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /~matsu/link/index.php [L]</ifmodule>