Rewrites organization

- Create lib/rewrites.php and move everything from lib/htaccess.php
except the H5BP htaccess functionality into it

- In the config, change add_theme_support('rewrite-urls') to
add_theme_support('rewrites')

- Remove the Apache/LightSpeed HTTPD check for rewrites

- Update docs with better Nginx rewrite rules
This commit is contained in:
Ben Word
2013-02-04 19:56:42 -06:00
parent df6a72e839
commit fea92a61aa
8 changed files with 148 additions and 143 deletions

View File

@@ -45,7 +45,7 @@ This file contains HTML5 Boilerplate's `.htaccess` which is automatically added
### htaccess.php
This file handles the clean URL rewrites and HTML5 Boilerplate `.htaccess`. [About the rewrites](rewrites.md).
This file handles the HTML5 Boilerplate `.htaccess`.
### init.php
@@ -55,6 +55,10 @@ This file runs the initial theme setup and defines helper constants for later us
This file contains all the custom nav modifications (for Bootstrap) and clean up.
### rewrites.php
This file handles the clean URL rewrites. [About the rewrites](rewrites.md).
### scripts.php
This file handles all of the CSS and JavaScript.

View File

@@ -3,7 +3,7 @@ table of contents](TOC.md)
# Rewrites
Rewrites are handled by `lib/htaccess.php`. Rewrites currently do not happen for child themes or network installs.
Rewrites are handled by `lib/rewrites.php`. Rewrites currently do not happen for child themes or network installs.
Rewrite:
@@ -14,18 +14,15 @@ Rewrite:
If HTML5 Boilerplate's `.htaccess` support is enabled in `lib/config.php`, then the `generate_rewrite_rules()` filter is used to automatically add the contents of `lib/h5bp-htaccess` to your `.htaccess` file.
## Alternative configuration
First remove the `if` statement that wraps everything, since if you're not on Apache or Litespeed then Roots will not apply the functionality.
## Alternative server configurations
### Nginx
if (!-e $request_filename) {
rewrite ^/assets/css/(.*)$ /wp-content/themes/roots/assets/css/$1 last;
rewrite ^/assets/js/(.*)$ /wp-content/themes/roots/assets/js/$1 last;
rewrite ^/assets/img/(.*)$ /wp-content/themes/roots/assets/img/$1 last;
rewrite ^/plugins/(.*)$ /wp-content/plugins/$1 last;
break;
location ~ ^/assets/(img|js|css)/(.*)$ {
try_files $uri $uri/ /wp-content/themes/roots/assets/$1/$2;
}
location ~ ^/plugins/(.*)$ {
try_files $uri $uri/ /wp-content/plugins/$1;
}
### Lighttpd

View File

@@ -42,6 +42,7 @@ A basic Roots theme initially looks like this:
│ ├── htaccess.php
│ ├── init.php
│ ├── nav.php
│ ├── rewrites.php
│ ├── scripts.php
│ ├── sidebar.php
│ ├── utils.php