Mod rewrite mod rewrite通过一个index.php引导所有流量
好的,我有一个模版重写(经过大量挖掘后获得:): 它将所有流量重定向到我的服务器的公共webroot中的loader.php。然后加载程序相应地加载相应的php文件,这是非常有趣的东西Mod rewrite mod rewrite通过一个index.php引导所有流量,mod-rewrite,frameworks,Mod Rewrite,Frameworks,好的,我有一个模版重写(经过大量挖掘后获得:): 它将所有流量重定向到我的服务器的公共webroot中的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
<?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和图像文件,并导致一系列致命错误
有人知道如何更改mod rewrite以允许非php文件跳过此重定向吗
或//
在images、css和js目录中添加另一个.htaccess文件以忽略父.htaccess会更好吗?通过向main.htacecss添加新规则 重写条件%{REQUEST_URI}!。(gif | jpg | png | css | html | js)$
这只是添加了一个必须匹配的条件:如果文件扩展名不是以下任何一个。。。由于图像将失败,重写规则将不会应用于图像。尝试仅包含.php文件,如下所示:
RewriteEngine On
RewriteBase /
$ Add this line
RewriteCond %{REQUEST_URI} /\w+\.php
# Prevent loop
RewriteCond %{REQUEST_URI} !/loader\.php
RewriteRule ^(.*)$ loader.php/$1?%{QUERY_STRING} [L]
通过添加新规则。。。重写条件%{REQUEST\u URI}!\。(gif | jpg | png | css | html | js)$感谢您的提示,非常感谢!
RewriteEngine On
RewriteBase /
$ Add this line
RewriteCond %{REQUEST_URI} /\w+\.php
# Prevent loop
RewriteCond %{REQUEST_URI} !/loader\.php
RewriteRule ^(.*)$ loader.php/$1?%{QUERY_STRING} [L]