Changeset 266

Show
Ignore:
Timestamp:
08/31/05 17:12:51 (3 years ago)
Author:
donncha
Message:

Major overhaul of rewrite rules, "main" blog now displays a "home" page.
Hopefully non-vhost install is working again.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/htaccess.dist

    r254 r266  
    22RewriteBase BASE/ 
    33 
    4 ### 
    5 #### main blog 
    6 ### 
    7  
    8 RewriteRule ^templates/(.*)                             BASE/wp-inst/wp-content/blogs/main/templates/$1 [L] 
    9 RewriteRule ^files/(.*)                                 BASE/wp-inst/wp-content/blogs/files/$1 [L] 
    10 RewriteRule ^wp-content/themes/(.*)                     BASE/wp-inst/wp-content/themes/$1 [L] 
    11  
    12 # rewrite these 
    13 RewriteRule ^category/(.*)/page/(.*)/                   BASE/wp-inst/index.php?wpblog=main&category_name=$1&paged=$2 [L] 
    14 RewriteRule ^category/(.*)/(feed|rdf|rss|rss2|atom)/?$  BASE/wp-inst/wp-feed.php?wpblog=main&category_name=$1&feed=$2 [L] 
    15 RewriteRule ^category/?(.*)                             BASE/wp-inst/index.php?wpblog=main&category_name=$1 [L] 
    16 RewriteRule ^author/(.*)/(feed|rdf|rss|rss2|atom)/?$    BASE/wp-inst/wp-feed.php?wpblog=main&author_name=$1&feed=$2 [L] 
    17 RewriteRule ^author/?(.*)                               BASE/wp-inst/index.php?wpblog=main&author_name=$1 [L] 
    18 RewriteRule ^([0-9]{4})/?([0-9]{1,2})?/?([0-9]{1,2})?/?([_0-9a-zA-Z-]+)?/?([0-9]+)?/?$          BASE/wp-inst/index.php?wpblog=main&year=$1&monthnum=$2&day=$3&name=$4&page=$5 [L] 
    19 RewriteRule ^([0-9]{4})/?([0-9]{1,2})/([0-9]{1,2})/([_0-9a-zA-Z-]+)/(feed|rdf|rss|rss2|atom)/?$ BASE/wp-inst/wp-feed.php?wpblog=main&year=$1&monthnum=$2&day=$3&name=$4&feed=$5 [L] 
    20 RewriteRule ^([0-9]{4})/?([0-9]{1,2})/([0-9]{1,2})/([_0-9a-zA-Z-]+)/trackback/?$                BASE/wp-inst/wp-trackback.php?wpblog=main&year=$1&monthnum=$2&day=$3&name=$4 [L] 
    21 RewriteRule ^page/?([0-9]+)?/?$                         BASE/wp-inst/index.php?paged=$1 [L] 
    22 RewriteRule ^feed/?([_0-9a-zA-Z-]+)?/?$                 BASE/wp-inst/wp-feed.php?wpblog=main&feed=$1 [L] 
    23 RewriteRule ^comments/feed/?([_0-9a-zA-Z-]+)?/?$        BASE/wp-inst/wp-feed.php?wpblog=main&feed=$1&withcomments=1 [L] 
    24 RewriteRule ^archives/p/([0-9]+)/?(.*)?                 BASE/wp-inst/index.php?wpblog=main&redirect=yes&p=$1 [L] 
    25 RewriteRule ^archives/cat/([0-9]+)/?(.*)?               BASE/wp-inst/index.php?wpblog=main&redirect=yes&cat=$1 [L] 
    26 RewriteRule ^archives/m/([0-9]+)\#?(.*)?                BASE/wp-inst/index.php?wpblog=main&redirect=yes&m=$1 [L] 
    27 RewriteRule ^b2rss2.php(.*)?                            BASE/wp-inst/wp-feed.php?wpblog=main&feed=rss2 [L] 
    28 RewriteRule ^b2rdf.php(.*)?                             BASE/wp-inst/wp-feed.php?wpblog=main&feed=rdf [L] 
    29  
    30 # We want to pass these files straight through 
    31 RewriteRule ^wp-comments-post.php(.*)                   BASE/wp-inst/wp-comments-post.php          [L] 
    32 RewriteRule ^go.php(.*)                                 BASE/wp-inst/go.php$1 [L] 
    33 RewriteRule ^pages/(.*)                                 BASE/wp-inst/pages/$1 [L] 
    34 RewriteRule ^wp-admin/(.*)                              BASE/wp-inst/wp-admin/$1 [L] 
    35 RewriteRule ^wp-atom.php(.*)                            BASE/wp-inst/wp-atom.php [L] 
    36 RewriteRule ^wp-comments-popup.php(.*)                  BASE/wp-inst/wp-comments-popup.php [L] 
    37 RewriteRule ^wp-comments-post.php(.*)                   BASE/wp-inst/wp-comments-post.php [L] 
    38 RewriteRule ^wp-commentsrss2.php(.*)                    BASE/wp-inst/wp-commentsrss2.php [L] 
    39 RewriteRule ^wp-counter.php(.+)?                        BASE/wp-inst/wp-counter.php [L] 
    40 RewriteRule ^wp-feed.php(.*)                            BASE/wp-inst/wp-feed.php [L] 
    41 RewriteRule ^wp-images/(.*)                             BASE/wp-inst/wp-images/$1 [L] 
    42 RewriteRule ^wp-includes/images/(.*)                    BASE/wp-inst/wp-includes/images/$1 [L] 
    43 RewriteRule ^wp-includes/js/(.*)                        BASE/wp-inst/wp-includes/js/$1 [L] 
    44 RewriteRule ^wp-links-opml.php(.*)                      BASE/wp-inst/wp-links-opml.php [L] 
    45 RewriteRule ^wp-login.php(.*)                           BASE/wp-inst/wp-login.php [L] 
    46 RewriteRule ^wp-mail.php(.*)                            BASE/wp-inst/wp-mail.php [L] 
    47 RewriteRule ^wp-pass.php(.*)                            BASE/wp-inst/wp-pass.php [L] 
    48 RewriteRule ^wp-rdf.php(.*)                             BASE/wp-inst/wp-rdf.php [L] 
    49 RewriteRule ^wp-register.php(.*)                        BASE/wp-inst/wp-register.php [L] 
    50 RewriteRule ^wp-rss.php(.*)                             BASE/wp-inst/wp-rss.php [L] 
    51 RewriteRule ^wp-rss2.php(.*)                            BASE/wp-inst/wp-rss2.php [L] 
    52 RewriteRule ^wp-sidebar.php(.*)                         BASE/wp-inst/wp-sidebar.php [L] 
    53 RewriteRule ^wp-trackback.php(.*)                       BASE/wp-inst/wp-trackback.php [L] 
    54 RewriteRule ^xmlrpc.php(.*)                             BASE/wp-inst/xmlrpc.php [L]    
    55 RewriteRule ^maintenance.php                            BASE/wp-inst/maintenance.php [L]    
    56 RewriteRule ^favicon.ico                                /wp-inst/favicon.ico [L] 
    57 RewriteRule ^robots.txt                                 /wp-inst/robots.txt [L] 
    58  
    59 RewriteRule ^wp-newblog.php                             BASE/wp-inst/wp-newblog.php [L] 
    60 RewriteRule ^signup/                                    BASE/wp-inst/wp-newblog.php [L] 
    61 RewriteRule ^invite/(.*)/?                              BASE/wp-inst/wp-newblog.php?u=$1 [L] 
    62 RewriteRule ^index.php                                  BASE/wp-inst/index.php [L] 
    63  
    64 RewriteRule ^$ BASE/wp-inst/index.php [L] 
    654 
    665### 
     
    7110RewriteRule ^([_0-9a-zA-Z-]+)/wp-content/blogs/(.*)/files/(.*)  BASE/wp-inst/wp-content/blogs/$1/files/$3 [L] 
    7211RewriteRule ^([_0-9a-zA-Z-]+)/wp-content/themes/(.*)            BASE/wp-inst/wp-content/themes/$2 [L] 
     12RewriteRule ^wp-content/themes/(.*)             BASE/wp-inst/wp-content/themes/$1 [L] 
    7313 
    7414# rewrite these 
     
    11454RewriteRule ^([_0-9a-zA-Z-]+)/xmlrpc.php(.*)                    BASE/wp-inst/xmlrpc.php [L]    
    11555RewriteRule ^([_0-9a-zA-Z-]+)/maintenance.php                   BASE/wp-inst/maintenance.php [L]    
    116 RewriteRule ^([_0-9a-zA-Z-]+)/favicon.ico                       /wp-inst/favicon.ico [L]    
     56RewriteRule ^([_0-9a-zA-Z-]+)/favicon.ico                       BASE/wp-inst/favicon.ico [L]    
     57RewriteRule ^([_0-9a-zA-Z-]+)/wp-includes/images/(.*)           BASE/wp-inst/wp-includes/images/$2 [L] 
     58RewriteRule ^([_0-9a-zA-Z-]+)/wp-includes/js/(.*)               BASE/wp-inst/wp-includes/js/$2 [L] 
    11759 
    118 # pages 
    119 RewriteCond REALPATH/wp-inst/wp-content/blogs/%{1} -d 
    120 RewriteRule ^([_0-9a-zA-Z-]+)/(.*)/$                            BASE/wp-inst/index.php?pagename=$2 [L] 
     60RewriteRule ^wp-newblog.php$                                    BASE/wp-inst/wp-newblog.php [L] 
     61RewriteRule ^wp-login.php                                       BASE/wp-inst/wp-login.php [L] 
     62RewriteRule ^wp-admin/(.*)                                      BASE/wp-inst/wp-admin/$1 [L] 
     63RewriteRule ^wp-includes/images/(.*)                            BASE/wp-inst/wp-includes/images/$1 [L] 
     64RewriteRule ^wp-includes/js/(.*)                                BASE/wp-inst/wp-includes/js/$1 [L] 
     65RewriteRule ^signup/                                            BASE/wp-inst/wp-newblog.php [L] 
     66RewriteRule ^invite/(.*)/?                                      BASE/wp-inst/wp-newblog.php?u=$1 [L] 
     67RewriteRule ^index.php                                          BASE/wp-inst/index.php [L] 
    12168 
    122 RewriteRule ^(.*)/$                                            BASE/wp-inst/index.php?pagename=$1 [L] 
     69RewriteRule ^$                                                         BASE/wp-inst/index.php [L] 
    12370 
    12471# catch all rules 
    125 RewriteCond REALPATH/wp-inst/wp-content/blogs/%{1} -d 
    12672RewriteRule ^([_0-9a-zA-Z-]+)/                                  BASE/wp-inst/index.php [L] 
    127  
    128 RewriteRule ^([_0-9a-zA-Z-]+)/(.+)$ BASE/wp-inst/$2 [L] 
    129  
    130 RewriteCond %{REQUEST_FILENAME}  -d 
    131 RewriteRule ^(.+[^/])$                                          BASE/ [R,L] 
    132 RewriteCond REALPATH/wp-inst/wp-content/blogs/%{1} -d 
    133 RewriteRule ^(.*[^/])$                                          BASE/$1/ [R,L] 
     73RewriteRule ^([_0-9a-zA-Z-]+)                                   $1/ [R,L] 
    13474 
    13575AddType text/css .css 
  • trunk/index.php

    r264 r266  
    6262<body> 
    6363 
    64 <div align="center"><img src="wp-inst/wp-images/wordpress-mu.png"></div><br> 
     64<div align="center"><img src="wp-inst/wp-includes/images/wordpress-mu.png"></div><br> 
    6565Welcome to WordPress MU, the Multi User Weblog System built on WordPress.<br><br> 
    6666'; 
     
    263263    <p>Each blog on your site will have their own hostname or 'sub domain'. Your blog addresses will appear like <span class='fakelink'>http://joesblog.example.com/</span> instead of <span class='fakelink'>http://www.example.com/joesblog/</span> but you need to do a few more things to Apache and your DNS settings before it'll work.</p> 
    264264    <p>Apache will have to have a <q>wildcard</q> alias configured in the virtual server definition of your server. You'll have to add a wildcard DNS record for your domain too. That's usually as easy as adding a <q>*</q> hostname in your online dns software.</p> 
     265    <p>Virtual Server Support: <input type='radio' name='vhost' value='yes'> Yes&nbsp;&nbsp;<input type='radio' name='vhost' value='no' checked>No</p> 
    265266    <p>More: <ul><li> <a href='http://codewalkers.com/archives/general_admin/234.html'>Sub-domain catch-all with Apache</a> via <a href='http://www.google.com/search?q=apache+wildcard+alias'>Google Search: apache wildcard alias</a></li><li> <a href='http://photomatt.net/2003/10/10/wildcard-dns-and-sub-domains/'>Wildcard dns and sub domains</a> via <a href='http://www.google.com/search?q=dns+wildcard+sub+domain'>Google Search: dns wildcard sub domain</a></li><li><a href='http://mu.wordpress.org/forums/topic/126#post-677'>mu forums: how to setup vhosts</a></li></ul></p> 
    266267    <br /> 
     
    350351            break; 
    351352            case "define('VHOST', ": 
    352                 fwrite($handle, str_replace("VHOSTSETTING", 'yes', $line)); 
     353                fwrite($handle, str_replace("VHOSTSETTING", $vhost, $line)); 
    353354            break; 
    354355            case '$table_prefix  =': 
     
    429430    if( $res == 'ok' ) { 
    430431            $url = "http://".$_SERVER["HTTP_HOST"] . $base; 
    431         $realpath = dirname(__FILE__); 
    432         do_htaccess( "htaccess.dist", ".htaccess", $realpath, $base, $url ); 
    433         do_htaccess( "wp-inst/htaccess.dist", "wp-inst/.htaccess", $realpath, $base, $url ); 
    434  
    435         $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator", "blog" ); 
    436         add_site_settings( "illegal_names", $illegal_names ); 
    437  
    438         print "<p>Well Done! Your blog has been set up and you have been sent details of your login and password in an email.</p>"; 
    439         print "<p>You may view your new blog by visiting <a href='".$url."'>".$url."</a>!</p>"; 
     432            update_option( "template", "home" ); 
     433            update_option( "stylesheet", "home" ); 
     434            add_site_option( "allowed_themes", 'a:2:{s:17:"WordPress Classic";b:1;s:17:"WordPress Default";b:1;}' ); 
     435            $realpath = dirname(__FILE__); 
     436            do_htaccess( "htaccess.dist", ".htaccess", $realpath, $base, $url ); 
     437            do_htaccess( "wp-inst/htaccess.dist", "wp-inst/.htaccess", $realpath, $base, $url ); 
     438 
     439            $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator", "blog" ); 
     440            add_site_settings( "illegal_names", $illegal_names ); 
     441 
     442            print "<p>Well Done! Your blog has been set up and you have been sent details of your login and password in an email.</p>"; 
     443            print "<p>You may view your new blog by visiting <a href='".$url."'>".$url."</a>!</p>"; 
    440444    } else { 
    441445        if( $res == 'error: problem creating blog entry' ) { 
  • trunk/wp-inst/wp-includes/wpmu-functions.php

    r264 r266  
    163163        $url = "http://".$domain.$path; 
    164164    } else { 
    165         if( $blogname == 'main' ) { 
    166             $url = "http://".$domain.$path; 
    167         } else { 
    168             $url = "http://".$domain.$path.$blogname; 
    169         } 
     165            if( $domain != $_SERVER[ 'HTTP_HOST' ] ) { 
     166                    $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 
     167                    if( $blogname != 'www.' ) { 
     168                            $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path . $blogname . '/'; 
     169                    } else { // we're installing the main blog 
     170                            $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; 
     171                    } 
     172            } else { // we're installing the main blog 
     173                    $url = 'http://' . $domain . $path; 
     174            } 
    170175    } 
    171176 
     
    251256    $message_headers = 'From: ' . stripslashes($weblog_title) . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>'; 
    252257    $message = $welcome_email; 
     258    if( empty( $current_site->site_name ) ) 
     259            $current_site->site_name = "WordPress MU"; 
    253260    @mail($admin_email, __('New ' . $current_site->site_name . ' Blog').": ".stripslashes( $weblog_title ), $message, $message_headers); 
    254261 
  • trunk/wp-inst/wp-newblog.php

    r131 r266  
    9696    $result = dirname( $_SERVER["SCRIPT_NAME"] );        
    9797    $result = str_replace("wp-inst","",$result); 
     98    /* 
    9899    if( strlen( $result > 1 ) && substr($result, -1 ) == '/') { 
    99100        $result = substr($result, 0, -1); 
    100101    } 
     102    */ 
    101103 
    102104    return $result; 
  • trunk/wp-inst/wp-settings.php

    r255 r266  
    9494    } 
    9595} 
    96 $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$base'"); 
     96if( defined( "VHOST" ) && constant( "VHOST" ) == 'yes' ) { 
     97        $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '$base'"); 
     98} else { 
     99        if( $base == '/' ) { 
     100                $wpblog = substr( $_SERVER[ 'REQUEST_URI' ], 1 ); 
     101        } else { 
     102                $wpblog = str_replace( $base, '', $_SERVER[ 'REQUEST_URI' ] ); 
     103        } 
     104        if( strpos( $wpblog, '/' ) ) 
     105                $wpblog = substr( $wpblog, 0, strpos( $wpblog, '/' ) ); 
     106        if( $wpblog == '' || file_exists( ABSPATH . $wpblog ) || is_dir( ABSPATH . $wpblog ) ) { 
     107                $searchdomain = $domain; 
     108        } else { 
     109                $searchdomain = $wpblog . "." . $domain; 
     110        } 
     111        $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '{$searchdomain}' AND path = '$base'"); 
     112
    97113if( $current_blog == false ) { 
    98114    is_installed(); 
     
    114130} 
    115131 
    116 if( $current_site->domain == $domain && $current_site->path == $base ) { 
    117         $wpblog = 'main'; 
    118 } 
    119132if( $blog_id == false ) { 
    120133    // no blog found, are we installing? Check if the table exists.