Eliminate use of DOCUMENT_ROOT. Look for .htaccess in 'home'.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-08-27 05:20:59 +00:00
parent 9fda8f6ca6
commit e8aa594ebd
2 changed files with 21 additions and 6 deletions

View File

@ -20,6 +20,16 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
} }
} }
$home = get_settings('home');
if ($home != '' && $home != get_settings('siteurl')) {
$home_path = parse_url($home);
$home_path = $home_root['path'];
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
$home_path = $root . $home_path . "/";
} else {
$home_path = ABSPATH;
}
require_once('./optionhandler.php'); require_once('./optionhandler.php');
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
@ -47,7 +57,7 @@ if (isset($_POST['submit'])) {
<?php if(isset($_POST['rules'])) { <?php if(isset($_POST['rules'])) {
$rules = explode("\n", $_POST['rules']); $rules = explode("\n", $_POST['rules']);
if(insert_with_markers(ABSPATH.'.htaccess', 'WordPress', $rules)) { if(insert_with_markers($home_path.'.htaccess', 'WordPress', $rules)) {
?> ?>
<div class="updated" id="htupdate"><p><?php _e('mod_rewrite rules written to .htaccess.'); ?></p></div> <div class="updated" id="htupdate"><p><?php _e('mod_rewrite rules written to .htaccess.'); ?></p></div>
<?php <?php
@ -136,7 +146,8 @@ if (isset($_POST['submit'])) {
</textarea> </textarea>
</p> </p>
<?php <?php
if ((! file_exists(ABSPATH.'.htaccess') && is_writable(ABSPATH)) || is_writable(ABSPATH.'.htaccess')) {
if ((! file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')) {
?> ?>
<p class="submit"> <p class="submit">
<input type="submit" name="writerules" value="<?php _e('Write mod_rewrite rules to .htaccess &raquo;') ?>"> <input type="submit" name="writerules" value="<?php _e('Write mod_rewrite rules to .htaccess &raquo;') ?>">

View File

@ -97,10 +97,14 @@ update_option('recently_edited', array(1, 2, 3) );
} }
$home = get_settings('home'); $home = get_settings('home');
if ($home != '' && ('index.php' == $file || get_settings('blogfilename') == $file)) { if (($home != '' && $home != get_settings('siteurl')) &&
$home_root = str_replace('http://', '', $home); ('index.php' == $file || get_settings('blogfilename') == $file ||
$home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root); '.htaccess' == $file)) {
$real_file = $_SERVER['DOCUMENT_ROOT'] . $home_root . '/' . $file; $home_root = parse_url($home);
$home_root = $home_root['path'];
$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
$home_root = $root . $home_root;
$real_file = $home_root . '/' . $file;
} else { } else {
$file = validate_file($file); $file = validate_file($file);
$real_file = '../' . $file; $real_file = '../' . $file;