忽略.htaccess中的特定URL

时间:2015-02-25 16:42:30

标签: apache .htaccess mod-rewrite

我的.htaccess文件中有一组标准的WordPress重写:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

但我想避免对特定网址进行任何重写,即:

http://www.domain.com/wp-content/themes/jarvis_wp/css/i?w=400&amp;h=250

我尝试将此规则添加到WordPress上面重写:

RewriteRule ^css - [L,NC]

但这似乎不起作用。如何让浏览器加载该URL而不进行任何重写?

这是index.php文件中的代码,它位于“i”文件夹中,也许这可能与重定向有关,我不确定它的来源:

<?php
// Include placeholder generator class
require('placeholder.class.php');

// Get variables from $_GET
$width           = isset($_GET['w']) ? trim($_GET['w']) : null;
$height          = isset($_GET['h']) ? trim($_GET['h']) : null;
$backgroundColor = isset($_GET['bgColor']) ? strtolower(trim($_GET['bgColor'])) : null;
$textColor       = isset($_GET['textColor']) ? strtolower(trim($_GET['textColor'])) : null;
$cache           = isset($_GET['c']) && $_GET['c'] == 1 ? true : false;

try {
    $placeholder = new Placeholder();
    $placeholder->setWidth($width);
    $placeholder->setHeight($height);
    $placeholder->setCache($cache);
    if ($backgroundColor) $placeholder->setBackgroundColor($backgroundColor);
    if ($textColor) $placeholder->setTextColor($textColor);
    $placeholder->render();
} catch (Exception $e){
    die($e->getMessage());
}

谢谢!

2 个答案:

答案 0 :(得分:0)

而不是

RewriteRule ^css - [L,NC]

RewriteRule ^wp-content/themes/jarvis_wp/css/i - [L]

答案 1 :(得分:0)

您可以告诉它忽略wp-content文件夹,这样它就不会重写。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/wp-content [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>