關於tp的apache 的.htaccess文件

爲了在url中隱藏index.php,需要寫 RewriteRule

查看phpinfo() 打印的Server API: Apache 2.0 Handler
查看phpinfo() 打印的Server API: CGI/FastCGI

==================================================================
默認的:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
==================================================================
如果爲 Server API: CGI/FastCGI 需要修改爲:

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
==================================================================
如果 Apache 的配置文件中使用 Alias 映射訪問目錄
Alias /sports "D:/WorkSpace/Sports/public/"
需要加上 Rewritebase /sports
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
Rewritebase /sports
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章