1523 |
1523 |
1524 // robots.txt -only if installed at the root |
1524 // robots.txt -only if installed at the root |
1525 $home_path = parse_url( home_url() ); |
1525 $home_path = parse_url( home_url() ); |
1526 $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); |
1526 $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); |
1527 |
1527 |
1528 // Old feed files |
1528 // Old feed and service files |
1529 $old_feed_files = array( '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old' ); |
1529 $deprecated_files = array( |
|
1530 '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old', |
|
1531 '.*wp-app\.php(/.*)?$' => $this->index . '?error=403', |
|
1532 ); |
1530 |
1533 |
1531 // Registration rules |
1534 // Registration rules |
1532 $registration_pages = array(); |
1535 $registration_pages = array(); |
1533 if ( is_multisite() && is_main_site() ) { |
1536 if ( is_multisite() && is_main_site() ) { |
1534 $registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true'; |
1537 $registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true'; |
1583 $this->extra_rules_top = array_merge($this->extra_rules_top, $rules); |
1586 $this->extra_rules_top = array_merge($this->extra_rules_top, $rules); |
1584 } |
1587 } |
1585 |
1588 |
1586 // Put them together. |
1589 // Put them together. |
1587 if ( $this->use_verbose_page_rules ) |
1590 if ( $this->use_verbose_page_rules ) |
1588 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $old_feed_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); |
1591 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); |
1589 else |
1592 else |
1590 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $old_feed_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); |
1593 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); |
1591 |
1594 |
1592 do_action_ref_array('generate_rewrite_rules', array(&$this)); |
1595 do_action_ref_array('generate_rewrite_rules', array(&$this)); |
1593 $this->rules = apply_filters('rewrite_rules_array', $this->rules); |
1596 $this->rules = apply_filters('rewrite_rules_array', $this->rules); |
1594 |
1597 |
1595 return $this->rules; |
1598 return $this->rules; |
1636 */ |
1639 */ |
1637 function mod_rewrite_rules() { |
1640 function mod_rewrite_rules() { |
1638 if ( ! $this->using_permalinks() ) |
1641 if ( ! $this->using_permalinks() ) |
1639 return ''; |
1642 return ''; |
1640 |
1643 |
1641 $site_root = parse_url(get_option('siteurl')); |
1644 $site_root = parse_url( site_url() ); |
1642 if ( isset( $site_root['path'] ) ) |
1645 if ( isset( $site_root['path'] ) ) |
1643 $site_root = trailingslashit($site_root['path']); |
1646 $site_root = trailingslashit($site_root['path']); |
1644 |
1647 |
1645 $home_root = parse_url(home_url()); |
1648 $home_root = parse_url(home_url()); |
1646 if ( isset( $home_root['path'] ) ) |
1649 if ( isset( $home_root['path'] ) ) |
1724 $rules .= '<configuration> |
1727 $rules .= '<configuration> |
1725 <system.webServer> |
1728 <system.webServer> |
1726 <rewrite> |
1729 <rewrite> |
1727 <rules>'; |
1730 <rules>'; |
1728 } |
1731 } |
1729 if ( !is_multisite() ) { |
1732 |
1730 $rules .= ' |
1733 $rules .= ' |
1731 <rule name="wordpress" patternSyntax="Wildcard"> |
1734 <rule name="wordpress" patternSyntax="Wildcard"> |
1732 <match url="*" /> |
1735 <match url="*" /> |
1733 <conditions> |
1736 <conditions> |
1734 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> |
1737 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> |
1735 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> |
1738 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> |
1736 </conditions> |
|
1737 <action type="Rewrite" url="index.php" /> |
|
1738 </rule>'; |
|
1739 } else { |
|
1740 if (is_subdomain_install()) { |
|
1741 $rules .= ' |
|
1742 <rule name="wordpress - Rule 1" stopProcessing="true"> |
|
1743 <match url="^index\.php$" ignoreCase="false" /> |
|
1744 <action type="None" /> |
|
1745 </rule> |
|
1746 <rule name="wordpress - Rule 2" stopProcessing="true"> |
|
1747 <match url="^files/(.+)" ignoreCase="false" /> |
|
1748 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" /> |
|
1749 </rule> |
|
1750 <rule name="wordpress - Rule 3" stopProcessing="true"> |
|
1751 <match url="^" ignoreCase="false" /> |
|
1752 <conditions logicalGrouping="MatchAny"> |
|
1753 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> |
|
1754 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> |
|
1755 </conditions> |
1739 </conditions> |
1756 <action type="None" /> |
1740 <action type="Rewrite" url="index.php" /> |
1757 </rule> |
1741 </rule>'; |
1758 <rule name="wordpress - Rule 4" stopProcessing="true"> |
1742 |
1759 <match url="." ignoreCase="false" /> |
|
1760 <action type="Rewrite" url="index.php" /> |
|
1761 </rule>'; |
|
1762 } else { |
|
1763 $rules .= ' |
|
1764 <rule name="wordpress - Rule 1" stopProcessing="true"> |
|
1765 <match url="^index\.php$" ignoreCase="false" /> |
|
1766 <action type="None" /> |
|
1767 </rule> |
|
1768 <rule name="wordpress - Rule 2" stopProcessing="true"> |
|
1769 <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> |
|
1770 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> |
|
1771 </rule> |
|
1772 <rule name="wordpress - Rule 3" stopProcessing="true"> |
|
1773 <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> |
|
1774 <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> |
|
1775 </rule> |
|
1776 <rule name="wordpress - Rule 4" stopProcessing="true"> |
|
1777 <match url="^" ignoreCase="false" /> |
|
1778 <conditions logicalGrouping="MatchAny"> |
|
1779 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> |
|
1780 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> |
|
1781 </conditions> |
|
1782 <action type="None" /> |
|
1783 </rule> |
|
1784 <rule name="wordpress - Rule 5" stopProcessing="true"> |
|
1785 <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" /> |
|
1786 <action type="Rewrite" url="{R:1}" /> |
|
1787 </rule> |
|
1788 <rule name="wordpress - Rule 6" stopProcessing="true"> |
|
1789 <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> |
|
1790 <action type="Rewrite" url="{R:2}" /> |
|
1791 </rule> |
|
1792 <rule name="wordpress - Rule 7" stopProcessing="true"> |
|
1793 <match url="." ignoreCase="false" /> |
|
1794 <action type="Rewrite" url="index.php" /> |
|
1795 </rule>'; |
|
1796 } |
|
1797 } |
|
1798 if ( $add_parent_tags ) { |
1743 if ( $add_parent_tags ) { |
1799 $rules .= ' |
1744 $rules .= ' |
1800 </rules> |
1745 </rules> |
1801 </rewrite> |
1746 </rewrite> |
1802 </system.webServer> |
1747 </system.webServer> |
1993 * |
1938 * |
1994 * @param string $permalink_structure Permalink structure. |
1939 * @param string $permalink_structure Permalink structure. |
1995 */ |
1940 */ |
1996 function set_permalink_structure($permalink_structure) { |
1941 function set_permalink_structure($permalink_structure) { |
1997 if ( $permalink_structure != $this->permalink_structure ) { |
1942 if ( $permalink_structure != $this->permalink_structure ) { |
|
1943 $old_permalink_structure = $this->permalink_structure; |
1998 update_option('permalink_structure', $permalink_structure); |
1944 update_option('permalink_structure', $permalink_structure); |
1999 $this->init(); |
1945 $this->init(); |
2000 do_action('permalink_structure_changed', $this->permalink_structure, $permalink_structure); |
1946 do_action('permalink_structure_changed', $old_permalink_structure, $permalink_structure); |
2001 } |
1947 } |
2002 } |
1948 } |
2003 |
1949 |
2004 /** |
1950 /** |
2005 * Set the category base for the category permalink. |
1951 * Set the category base for the category permalink. |