疑似静的化(動的ページURLを静的ページに見せかける)
疑似静的化と言っても、世の中には様々なURLが存在します。
今回は、いくつかのパターンを例に上げて紹介します。
パターン①
https://example.com/?id=1
を
https://example.com/url-test.html
に見せかける。
↓
RewriteRule ^url-test.html$ /?id=1 [L]
パターン②
http://example.com/?id=1
を
http://example.com/url-test/
に見せかける。
↓
RewriteRule ^url-test/$ /?id=1 [L]
パターン③
http://example.com/detail.php?id=1
を
http://example.com/1.html
に見せかける。
↓
RewriteRule ^(.*).html$ detail.php?id=$1 [L]
パターン④
http://example.com/list.php?category=test
を
http://example.com/category/test.html
に見せかける。
↓
RewriteRule ^category/(.*).html$ list.php?category=$1 [L]
パターン⑤
https://example.com/blog/index.php?category=test
を
https://example.com/blog/category/test
に見せかける。
※URLの最後にスラッシュ(/)なし
↓
RewriteRule ^category/(.*)$ /blog/index.php?category=$1
パターン⑥
https://example.com/blog/index.php?category=test
を
https://example.com/blog/category/test/
に見せかける。
※URLの最後にスラッシュ(/)あり
↓
RewriteRule ^category/(.*)/$ /blog/index.php?category=$1