From 8662dfbc3335133487d9dc9a778c2ca7ac81e462 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 27 Dec 2004 22:30:52 +0000 Subject: [PATCH] Leave htaccess alone if permalinks are not turned on. Bug 597. git-svn-id: https://develop.svn.wordpress.org/trunk@2006 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-functions.php | 21 +++++++++------------ wp-includes/classes.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 773f6381ac..e05ee2f5b9 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -497,20 +497,17 @@ function save_mod_rewrite_rules() { global $is_apache, $wp_rewrite; $home_path = get_home_path(); - if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) - $writable = true; - else - $writable = false; + if (! $wp_rewrite->using_mod_rewrite_permalinks()) + return; - if ($wp_rewrite->using_index_permalinks()) - $usingpi = true; - else - $usingpi = false; + if ( ! ((!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')) ) + return; - if ( $writable && !$usingpi && $is_apache ) { - $rules = explode("\n", $wp_rewrite->mod_rewrite_rules()); - insert_with_markers($home_path.'.htaccess', 'WordPress', $rules); - } + if (! $is_apache) + return; + + $rules = explode("\n", $wp_rewrite->mod_rewrite_rules()); + insert_with_markers($home_path.'.htaccess', 'WordPress', $rules); } function generate_page_rewrite_rules() { diff --git a/wp-includes/classes.php b/wp-includes/classes.php index c910eb515e..7c1e34ce8b 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -764,6 +764,13 @@ class WP_Rewrite { 's=' ); + function using_permalinks() { + if (empty($this->permalink_structure)) + return false; + else + return true; + } + function using_index_permalinks() { if (empty($this->permalink_structure)) { return false; @@ -777,6 +784,13 @@ class WP_Rewrite { return false; } + function using_mod_rewrite_permalinks() { + if ( $this->using_permalinks() && ! $this->using_index_permalinks()) + return true; + else + return false; + } + function preg_index($number) { $match_prefix = '$'; $match_suffix = ''; @@ -1058,6 +1072,10 @@ class WP_Rewrite { } function mod_rewrite_rules () { + if ( ! $this->using_permalinks()) { + return ''; + } + $site_root = str_replace('http://', '', trim(get_settings('siteurl'))); $site_root = preg_replace('|([^/]*)(.*)|i', '$2', $site_root); if ('/' != substr($site_root, -1)) $site_root = $site_root . '/';