mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
Write rewrite rules to .htacces if .htaccess is writable. Create .htaccess if it does not exist and the directory is writable. Props to Owen Winkler.
git-svn-id: https://develop.svn.wordpress.org/trunk@1489 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1352,6 +1352,31 @@ function rewrite_rules($matches = '', $permalink_structure = '') {
|
||||
return $rewrite;
|
||||
}
|
||||
|
||||
function mod_rewrite_rules ($permalink_structure) {
|
||||
$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 . '/';
|
||||
|
||||
$home_root = str_replace('http://', '', trim(get_settings('home')));
|
||||
$home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
|
||||
if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
|
||||
|
||||
$rules = "RewriteEngine On\n";
|
||||
$rules .= "RewriteBase $home_root\n";
|
||||
$rewrite = rewrite_rules('', $permalink_structure);
|
||||
foreach ($rewrite as $match => $query) {
|
||||
if (strstr($query, 'index.php')) {
|
||||
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n";
|
||||
} else {
|
||||
$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n";
|
||||
}
|
||||
}
|
||||
|
||||
$rules = apply_filters('rewrite_rules', $rules);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
function get_posts($args) {
|
||||
global $wpdb;
|
||||
parse_str($args, $r);
|
||||
|
||||
Reference in New Issue
Block a user