行,我有這個mod重寫(多挖後獲得性:http://www.dynamicdrive.com/forums/showthread.php?51923-Pretty-URLs-with-basic-mod_rewrite-and-powerful-options-in-PHP):國防部重寫通道通過一個的index.php所有流量
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_URI} !^/loader.php$
RewriteCond %{REQUEST_URI} !^/loader.php/
RewriteRule ^(.*)$ loader.php/$1?%{QUERY_STRING} [L]
它的所有流量重定向到loader.php公共根目錄我的服務器。然後加載器相應地加載適當的php文件,相當標準的東西。
<?php
//load the definitions and functions
require_once '../www_private/functions/functions.php';
//If the user is looking for the index then the request will have been to a directory, add index.php accordingly
if (is_dir(WEBROOT.$_SERVER['REQUEST_URI']))
{
//check for a leading slash
if (substr($_SERVER['REQUEST_URI'], -1 == '/'))
{
$_SERVER['REQUEST_URI'] .= '/';
}
$_SERVER['REQUEST_URI'] .= 'index.php';
}
//Now attempt to load the requested file.
require WEBROOT.$_SERVER['REQUEST_URI'];
?>
唯一的問題是,它也重定向CSS JS和圖像文件,以及導致一堆致命錯誤...
有誰知道如何改變國防部重寫,允許非PHP文件跳過這個重定向?
或//
我會更好地只需添加另一個.htaccess文件中的圖像,CSS和JS目錄忽略父的.htaccess?
通過添加新的規則...的RewriteCond%{REQUEST_URI} \(GIF | JPG | PNG | CSS | HTML | JS)$! – John