TP 5は隠し入口indexを配置する.phpファイル
3836 ワード
非表示のindex.php
PS:ここでいうエントリファイルとは、パブリック/indexを指す.phpファイル、プロファイルはこのディレクトリの下にあります
URLアドレスのエントリファイル
次のURLアドレスでアクセスできます
英語の
PS:ここでいうエントリファイルとは、パブリック/indexを指す.phpファイル、プロファイルはこのディレクトリの下にあります
URLアドレスのエントリファイル
index.php
は削除できますが、WEBサーバの書き換えルールを追加して構成する必要があります.Apache
を例にとると、ファイルエントリを必要とする同級に.htaccess
ファイル(公式デフォルトではこのファイルが付属しています)を追加します.内容は以下の通りです.
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
phpstudy
を使用する場合、ルールは次のとおりです.
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
index.php public
の場合、ルールは次のとおりです.
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php [L,E=PATH_INFO:$1]
次のURLアドレスでアクセスできます
http://tp5.com/index/index/index
http://tp5.com/index/index/hello
apache
バージョンで上記の方法でindex.php
を正常に隠すことができない場合は、.htaccess
ファイルを次の方法で構成してみてください.
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
英語の
Nginx
環境であれば、教育はNginx.conf
に追加できます.location / { // …..
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}