Make WordPress Core


Ignore:
Timestamp:
07/27/2004 11:37:45 PM (21 years ago)
Author:
rboren
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r1480 r1489  
    13531353}
    13541354
     1355function mod_rewrite_rules ($permalink_structure) {
     1356    $site_root = str_replace('http://', '', trim(get_settings('siteurl')));
     1357    $site_root = preg_replace('|([^/]*)(.*)|i', '$2', $site_root);
     1358    if ('/' != substr($site_root, -1)) $site_root = $site_root . '/';
     1359   
     1360    $home_root = str_replace('http://', '', trim(get_settings('home')));
     1361    $home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
     1362    if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
     1363   
     1364    $rules = "RewriteEngine On\n";
     1365    $rules .= "RewriteBase $home_root\n";
     1366    $rewrite = rewrite_rules('', $permalink_structure);
     1367    foreach ($rewrite as $match => $query) {
     1368        if (strstr($query, 'index.php')) {
     1369            $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n";
     1370        } else {
     1371            $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n";
     1372        }
     1373    }
     1374
     1375    $rules = apply_filters('rewrite_rules', $rules);
     1376
     1377    return $rules;
     1378}
     1379
    13551380function get_posts($args) {
    13561381    global $wpdb;
Note: See TracChangeset for help on using the changeset viewer.