0
0

More than 1 year has passed since last update.

.htaccess

Last updated at Posted at 2021-12-04

リダイレクトテンプレート

order deny,allow
allow from all
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !^(.*)\.(gif|png|jpg|css|ico|js)$ [NC]
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

Options Indexes FollowSymLinks SymLinksIfOwnerMatch


####################
#   mod_rewrite    #
####################
# rewriteLogを確認する
# 
# チェックポイント1 : httpd.confでAllowOverrideがallになっているか
#<Directory "/var/www/html">
#    Options Indexes FollowSymLinks
#    AllowOverride all
#</Directory>

# チェックポイント2 : .htaccessは有効になっているか
# 構文エラーになるように冒頭に「test」と記述してみる
# Internal Server ErrorになればOK

# チェックポイント3 : rewriteモジュールのロードチェック
# $ httpd -M | grep rewrite
# 「rewrite_module (shared)」と表示されればOK

# テスト用
#<IfModule mod_rewrite.c>
#     RewriteEngine On
#     ErrorDocument 404 http://www.google.co.jp/
#</IfModule>


# 特殊な例
# 受けたURLに対する情報をRewriteMapから当ててrewriteさせる
# RewriteMap usmap text:/var/hogehoge/user-server.txt
# RewriteRule ^/harc/json/(.*?)/(.*?) $ https://$[usmap:$1].api-robot.com/harc/json/$1/$2 [P,L]

URLでの分岐方法

    RewriteCond %{REQUEST_URI} !(^/api/)
    RewriteRule ^(.*)$ index.html [QSA,L]

    RewriteCond %{REQUEST_URI} (^/api/)
    RewriteRule ^(.*)$ index.php [QSA,L]
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