Make WordPress Core

Changeset 2635


Ignore:
Timestamp:
06/13/2005 02:09:24 AM (20 years ago)
Author:
ryan
Message:

Parse REQUEST_URI as a permalink if it looks permalinkish. Use reduced mod_rewrite rules by default.

File:
1 edited

Legend:

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

    r2627 r2635  
    627627
    628628        if ($this->is_category) {
    629             $category = &get_category($this->get('cat'));
     629            $cat = $this->get('cat');
     630            $category = &get_category($cat);
    630631            $this->queried_object = &$category;
    631             $this->queried_object_id = $this->get('cat');
     632            $this->queried_object_id = $cat;
    632633        } else if ($this->is_single) {
    633634            $this->queried_object = $this->post;
     
    754755    var $matches = '';
    755756    var $rules;
     757    var $use_verbose_rules = false;
    756758    var $rewritecode =
    757759        array(
     
    12201222        $rules .= "RewriteEngine On\n";
    12211223        $rules .= "RewriteBase $home_root\n";
    1222         $this->matches = '';
    1223         $rewrite = $this->rewrite_rules();
    1224         $num_rules = count($rewrite);
    1225         $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
    1226             "RewriteCond %{REQUEST_FILENAME} -d\n" .
    1227             "RewriteRule ^.*$ - [S=$num_rules]\n";
    1228 
    1229         foreach ($rewrite as $match => $query) {
    1230             // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    1231             $match = str_replace('.+?', '.+', $match);
    1232 
    1233             // If the match is unanchored and greedy, prepend rewrite conditions
    1234             // to avoid infinite redirects and eclipsing of real files.
    1235             if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
    1236                 //nada.
    1237             }
    1238 
    1239             if (strstr($query, $this->index)) {
    1240                 $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
    1241             } else {
    1242                 $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
    1243             }
    1244         }
     1224
     1225        if ($this->use_verbose_rules) {
     1226            $this->matches = '';
     1227            $rewrite = $this->rewrite_rules();
     1228            $num_rules = count($rewrite);
     1229            $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
     1230                "RewriteCond %{REQUEST_FILENAME} -d\n" .
     1231                "RewriteRule ^.*$ - [S=$num_rules]\n";
     1232       
     1233            foreach ($rewrite as $match => $query) {
     1234                // Apache 1.3 does not support the reluctant (non-greedy) modifier.
     1235                $match = str_replace('.+?', '.+', $match);
     1236
     1237                // If the match is unanchored and greedy, prepend rewrite conditions
     1238                // to avoid infinite redirects and eclipsing of real files.
     1239                if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
     1240                    //nada.
     1241                }
     1242           
     1243                if (strstr($query, $this->index)) {
     1244                    $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
     1245                } else {
     1246                    $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
     1247                }
     1248            }
     1249        } else {
     1250            $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
     1251                "RewriteCond %{REQUEST_FILENAME} !-d\n" .
     1252                "RewriteRule . {$home_root}{$this->index}\n";
     1253        }
     1254
    12451255        $rules .= "</IfModule>\n";
    12461256
     
    13041314            parse_str($extra_query_vars, $extra_query_vars);
    13051315
    1306         // Process PATH_INFO and 404.
     1316        // Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
    13071317        if ((isset($_GET['error']) && $_GET['error'] == '404') ||
    13081318                ((! empty($_SERVER['PATH_INFO'])) &&
    13091319                 ('/' != $_SERVER['PATH_INFO']) &&
    13101320                 (false === strpos($_SERVER['PATH_INFO'], '.php'))
    1311                  )) {
     1321                 ) ||
     1322                (empty($_SERVER['QUERY_STRING']) &&
     1323                 (false === strpos($_SERVER['REQUEST_URI'], '.php')) &&
     1324                 ('/' != $_SERVER['REQUEST_URI']))
     1325                ) {
    13121326
    13131327            $this->did_permalink = true;
Note: See TracChangeset for help on using the changeset viewer.