Last active
April 15, 2017 01:24
-
-
Save katsuobushiFPGA/c4ab000c65b958db3740b0ad6d0c010c to your computer and use it in GitHub Desktop.
.htaccessに関するメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###CakePHPで一部だけコントロール下にしたい | |
- httpdocs (ドキュメントルート) | |
- a | |
-index.html | |
- b | |
-index.html | |
- c | |
-index.html | |
- d | |
-index.html | |
この中の、cだけCakePHPで制御できるようにする。 | |
そのためには、c直下に下記のような.htaccessを書く。 | |
.htaccess | |
--- | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REQUEST_URI} (^/c/) | |
RewriteCond %{REQUEST_URI} !(^/c/index.html) | |
RewriteRule ^ ../index.php [L] | |
</IfModule> | |
--- | |
これにより、/c/でアクセスされたときは、cakephpで処理振り分けをするようにできる。 | |
/c/index.htmlの場合は、index.htmlを表示させる。 | |
###トレイリングスラッシュを付与 | |
###末尾にスラッシュつけるやつ | |
# ファイルやディレクトリが存在すれば表示 | |
RewriteCond %{REQUEST_FILENAME} -d [OR] | |
RewriteCond %{REQUEST_FILENAME} -f | |
RewriteRule ^ - [L] | |
# add Trailing Slash | |
RewriteRule ^(.+[^/])$ /$1/ [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment