[wp-cvs] wordpress/wp-includes functions.php,1.133,1.134

Ryan Boren rboren at users.sourceforge.net
Tue Jul 27 23:37:47 UTC 2004


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18486/wp-includes

Modified Files:
	functions.php 
Log 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.

Index: functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions.php,v
retrieving revision 1.133
retrieving revision 1.134
diff -C2 -d -r1.133 -r1.134
*** functions.php	23 Jul 2004 09:26:37 -0000	1.133
--- functions.php	27 Jul 2004 23:37:45 -0000	1.134
***************
*** 1353,1356 ****
--- 1353,1381 ----
  }
  
+ 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;




More information about the cvs mailing list