天天看點

TP5路由問題

想要隐藏index.php和能夠直接域名通路我們想要的首頁,那麼首先,要把我們伺服器位址指向該項目的public下面;如order項目:WWW/order/public;

然後在public檔案夾下面有個.htaccess檔案需設定為:

#<IfModule mod_rewrite.c>
#    Options +FollowSymlinks -Multiviews
#    RewriteEngine on
#
#    RewriteCond %{REQUEST_FILENAME} !-d
#    RewriteCond %{REQUEST_FILENAME} !-f
#    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
#</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>      
上面那個注釋的是原來的,差別是index.php?多了一個問号;這樣設定之後index.php就可以隐藏了;      
關于在route.php檔案裡面的配置:      
'__alias__' =>  [
    'my'  =>  ['index/index',['ext'=>'html']],
],
'index'=>'@index/Index/index'      
添加這些好像可以隐藏指定子產品、方法,這樣最後生成的url就可以是localhost/index.html這樣吧;