Welcome to WebmasterWorld Guest from 54.198.164.83
Forum Moderators: Ocean10000 & incrediBILL & phranque
# if this request is for any of these filetypes
RewriteCond $1 \.gif$ [NC,OR]
RewriteCond $1 \.jpg$ [NC,OR]
RewriteCond $1 \.ico$ [NC,OR]
RewriteCond $1 \.css$ [NC,OR]
RewriteCond $1 \.js$ [NC,OR]
RewriteCond $1 \.mp3$ [NC,OR]
RewriteCond $1 \.wav$ [NC,OR]
RewriteCond $1 \.pdf$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
Whereas in a server config file but outside of any <Directory> container, you'd want:
# if this request is for any of theses filetypes
RewriteCond $1 \.gif$ [NC,OR]
RewriteCond $1 \.jpg$ [NC,OR]
RewriteCond $1 \.ico$ [NC,OR]
RewriteCond $1 \.css$ [NC,OR]
RewriteCond $1 \.js$ [NC,OR]
RewriteCond $1 \.mp3$ [NC,OR]
RewriteCond $1 \.wav$ [NC,OR]
RewriteCond $1 \.pdf$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^/(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule ^/. /index.php [L]
These changes have to do with differences in performance of regex-ORs versus RewriteCond [OR]s* due to the fact that code in server config files is "pre-compiled" at server start-up as opposed to being interpreted on-the-fly in .htaccess, differences in the "local URL-path" as seen by the RewriteRule, and --as stated above-- the fact that mod_rewrite processing is not re-started from the top after any rule matches, as it is in .htaccess.
In your situation, this code may not be much faster that the box-stock code provided by WP. But if you serve any images, media, or document files whatsoever, it will be faster nonetheless.
Jim
# BEGIN WordPress
#
RewriteEngine on
#
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive
# RewriteBase /
#
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif¦jpg¦ico¦css¦js)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
#
# END wordpress
[edited by: tedster at 1:37 am (utc) on Mar 4, 2013]
[edit reason] fixed typo [/edit]