0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

URLの疑似静的化

Last updated at Posted at 2020-12-13

目的

ブログサイトでapacheのmod_rewriteモジュールを用いて動的ページ"review.php?id=16"を"review_16"に疑似静的化する

前提

Webサーバーはapacheを使用
当初URLパラメータでブログの記事の認識をしようとしていた(?id=xxx)が静的化を試みる
ほとんど、個人メモなので理解しやすく記述できてません。質問ある方はお気軽に!

mod_rewriteの設定

  • httpd.confの下記設定をする
LoadModule rewrite_module modules/mod_rewrite.so
  • .htaccessに下記を追加する
RewriteEngine On
RewriteRule ^review_([0-9]+)$ review.php?id=$1

結果

静的化により各ページ参照が出来るようになった

参考

動的ページSEO:URL擬似静的化

その他の参考記事

疑似静的化(動的ページURLを静的ページに見せかける)
基本的な正規表現一覧
Apache「mod_rewrite」の設定方法

補足

"+":直前の文字が 1回以上 繰り返す場合にマッチ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?