apache rewrite 隱藏 php 入口文件index.php

1. 先加載mod_rewriter

   在ubuntu 下 cgi 方式的 apache 下,先讓mod_rewrite 生效

   ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

2. 在web 站點配置,

   <directory "..."></directory>中有“allowoverride none” 改成  allowoverride FileInfo Options

3.在web根目錄下加.htacess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond $1 !^(index.php|flash|img|css|js|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

   

發佈了78 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章