WordPressの擬似URLの仕組みってこれだけだと思います( ´д)ヒソ(´д`)ヒソ(д` )

2015.01.23

Logging


 
WordPressの擬似URLの仕組みってこれだけだと思います。自分の記事は静的なアドレス(擬似)になっていると思います。これはWordPressの設定のパーマリンク設定を/%postname%.htmlこういうふうに設定しているからhtmlファイルで作ったようなURLで表示されているわけです。ちなみに公開途中でURLの表示設定をいじくると今まで検索で表示されていたものが全部飛んじゃうでSEO的にオススメできません。じゃ動的URLってなにかと言えば、zip358.com?p=1とか言うアドレスでページが表示されるURLを動的URLって言います。話し戻しまして、これってどういう仕組みで動いているのかと言う疑問符が付くと思います。答えはこういう感じ、あるURLを入力するとDBにそのURLは存在するかと言う問い合わせを検索かけます、検索を結果が有れば表示するという事をしているだけです。ちなみに.htaccessとphpの合わせ技になります。.htaccessに、あるURLが飛んできたらこのPHPを見てねという処理をしてあげれば良いわけです。.htaccessはURLを偽造できます。(ΦωΦ)フフフ…。
今回はDB処理検索を除いたサンプルサイトを作りましたのでご覧ください。
https://zip358.com/tool/sample-x/あいうえお.htmlこのサイトURLの日本語を変更しても拡張子を変更してもサイトが表示されます(※https://zip358.com/tool/sample-x/の移行URL変更だったらhttps://zip358.com/tool/sample-x/あいうえお/wawa.htmlでも同じサイトが表示されます。:存在しないURL以外、同じサイトを表示(ΦωΦ)フフフ…ヤバイか?)。
https://zip358.com/tool/sample-x/の配下に.htaccessファイルとindex.phpを置いています。
.htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /tool/sample-x/index.php [L]

index.php

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>zip358.com:sample-x</title>
<link rel="stylesheet" type="text/css" href="css/html5reset.css"  />
<style>
iframe { width: 95%; height: 95%; position: absolute; margin: 0; }
body{font-size:16pt;overflow:hidden;}
</style>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php
 echo '<a href="http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"].'">http://'.$_SERVER["HTTP_HOST"] .htmlspecialchars(urldecode ($_SERVER["REQUEST_URI"])).'</a>というアドレスを打ちましたね<br><br>';
?>
<iframe src="/tool/sample-x/html5up-twenty/index.html"  marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="auto">
</body>
</html>

タグ

AM, body&gt, br&gt, DOCTYPE html&gt, head&gt, htaccess, html5reset.css, html5up-twenty, if lt IE 9, iframe src, index.html, index.php, meta charset, RewriteCond, sample-x, sample-x&lt, script&gt, style&gt, title&gt, wawa.html, zip358.com, ,