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 1 year has passed since last update.

自分用メモ: クエリパラメータ渡し&拡張子隠し

Last updated at Posted at 2022-05-12

自分用にメモ。

.htaccess
<IfModule mod_rewrite.c>
    # RewriteEngineの起動
    RewriteEngine On
    # ファイル名の処理 (Ref: https://www.javadrive.jp/apache/htaccess/index9.html)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}\.php -f
    # クエリの抽出
    RewriteCond %{QUERY_STRING} (.+)
    
    # リダイレクト実行
    RewriteRule ^(.*)$ $1.php?%1 [L]
</IfModule>

実行例

https://example.com/mypage?user=0 => https://example.com/mypage.php?user=0

まとめ

もし困ってる人がいたら力になれればいいな…。

0
0
2

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?