cakephp htaccess file for website speed performance - performance

I want htaccess file code so my website performance for caching , image ,css, js loading can be speed up. So my website performance should fast in google insights and Gtmetrix

I have setup mine htaccess file for my all projects.you can configure like this
&ltIfModule mod_rewrite.c&gt
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
&lt/IfModule>
&ltifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 6 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
&lt/ifModule>
&ltifModule mod_headers.c>
&ltfilesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
&lt/filesMatch>
&ltfilesMatch "\.(css)$">
Header set Cache-Control "public"
&lt/filesMatch>
&ltfilesMatch "\.(js)$">
Header set Cache-Control "private"
&lt/filesMatch>
&ltfilesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
&lt/filesMatch>
Header unset ETag
&lt/ifModule>
FileETag None
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
&ltfiles *.html>
SetOutputFilter DEFLATE
&lt/files>
This may help you to speed up your website performance.Put it in root .htaccess file

Related

CodeIgniter Framework: 500 Internal Server Error

I am developing project using CodeIgniter framework and when I am running my project from Xampp it shows a 500 Internal Server Error. How to resolve Error 500 in CodeIgniter framework or Is this error of htaccess file?
SetEnv MAGIC_QUOTES 0
SetEnv PHP_VER 5
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /aip
RewriteCond %{REQUEST_URI} ^base.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{HTTP_HOST} ^(dishme\.com\.au)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|css|fonts|woff|ttf|eot|svg|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /aip/index.php?/$1 [L]
#Block libwww-perl attacks
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
Use this htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

index.php coming two times in magento url?

I am using magento v1.8.0.1. The problem is index.php coming two times in magento url like
http://103.16.130.92/index.php/index.php/admin/system_config/index/key/28a1cf7ee3eaa30083d383d0f70c7753/
I wanted to remove index.php from url for that i follow this link
http://stackoverflow.com/questions/16938860/how-do-i-remove-index-php-from-the-url-in-magento
But the problem is that it is not working and showing 404 error.
I searched all the stuffs but unable to remove index.php from url.
The code for .htaccrss file is
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php
############################################
## GoDaddy specific options
# Options -MultiViews
## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini
############################################
## this line is specific for 1and1 hosting
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php
############################################
## default index file
DirectoryIndex index.php
<IfModule mod_php5.c>
############################################
## adjust memory limit
# php_value memory_limit 64M
php_value memory_limit 256M
php_value max_execution_time 18000
############################################
## disable magic quotes for php request vars
php_flag magic_quotes_gpc off
############################################
## disable automatic session start
## before autoload was initialized
php_flag session.auto_start off
############################################
## enable resulting html compression
php_flag zlib.output_compression on
###########################################
# disable user agent verification to not break multiple image upload
php_flag suhosin.session.cryptua off
###########################################
# turn off compatibility with PHP4 when dealing with objects
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_ssl.c>
############################################
## make HTTPS env vars available for CGI mode
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
# RewriteBase /magento/
############################################
## uncomment next line to enable light API calls processing
# RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
############################################
## rewrite API2 calls to api.php (by now it is REST only)
RewriteRule ^api/rest api.php?type=rest [QSA,L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## redirect for mobile user agents
#RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
#RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
#RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead
AddDefaultCharset Off
#AddDefaultCharset UTF-8
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
############################################
## By default allow all access
Order allow,deny
Allow from all
###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version
<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
#FileETag none
<ifModule mod_headers.c>
# Turn on Expires and set default expires to 3 days
ExpiresActive On
ExpiresDefault A259200
# Set up caching on media files for 1 month
<filesMatch ".(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
ExpiresDefault A2419200
Header append Cache-Control "public"
</filesMatch>
# Set up 2 Hour caching on commonly updated files
<filesMatch ".(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "private, must-revalidate"
</filesMatch>
# Force no caching for dynamic files
<filesMatch ".(php|cgi|pl|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
</filesMatch>
</ifModule>
<IfModule mod_headers.c>
# YEAR
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# 45 MIN
<FilesMatch "\.(html|htm|txt)$">
Header set Cache-Control "max-age=86400"
</FilesMatch>
</IfModule>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl|asp|html)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
############################################
## compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>
###########################################
if anyone knows this, please help me out.
Thanks!
Open up phpMyAdmin or whichever database tool you have available for your site and enter the query:
SELECT * FROM `core_config_data` WHERE `path` LIKE 'web%url';
Make sure none of the returned values end with "index.php" because that really shouldn't be there. This is what a healthy result should look like:
+-----------+---------+----------+-----------------------------+-----------------------------+
| config_id | scope | scope_id | path | value |
+-----------+---------+----------+-----------------------------+-----------------------------+
| 6 | default | 0 | web/unsecure/base_url | http://www.example.com/ |
| 7 | default | 0 | web/secure/base_url | http://www.example.com/ |
| 15 | default | 0 | web/unsecure/base_link_url | {{unsecure_base_url}} |
| 16 | default | 0 | web/unsecure/base_skin_url | {{unsecure_base_url}}skin/ |
| 17 | default | 0 | web/unsecure/base_media_url | {{unsecure_base_url}}media/ |
| 18 | default | 0 | web/unsecure/base_js_url | {{unsecure_base_url}}js/ |
| 19 | default | 0 | web/secure/base_link_url | {{secure_base_url}} |
| 20 | default | 0 | web/secure/base_skin_url | {{secure_base_url}}skin/ |
| 21 | default | 0 | web/secure/base_media_url | {{secure_base_url}}media/ |
| 22 | default | 0 | web/secure/base_js_url | {{secure_base_url}}js/ |
+-----------+---------+----------+-----------------------------+-----------------------------+
If you had to adjust any rows clear the cache by deleting var/cache/* in the web folder.

Magento: set Time-to-Live (TTL) for certain CSS or JS files?

Is there a way to set the TTL in Magento for certain resources, like CSS and/or JS files? If not, is there a way to set it in general, for all resources? I searched the net, but couldnt find much.
Thanks for your help! :)
Maybe you want to use the .htaccess file:
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresDefault "access plus 1 year"
</IfModule>
Example:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>

wordpress subdomain for images htaccess problems

I'm trying to setup a sub domain for my wordpress images and i have been setting up the a virtualhost which is pointing to default wordpress upload directory. The problem is that the sub-domain is getting overridden by wordpress .htaccess.
the apache virtualhost
<VirtualHost *:80>
ServerName img.mydomain.com
ServerAlias img.mydomain.com
DocumentRoot C:/inetpub/wwwroot/mydomain.com/wp-content/uploads/
</VirtualHost>
if I call the subdomain I get an 502 Error
my .htaccess
#RewriteRule ^(.*)-en/?$ /$1/ [L]
RewriteCond %{HTTP_HOST} http://www.mydomain.com [NC]
#RewriteRule ^tag/(.*)$ http://www.mydomain.com/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/\d{2}/(.*)$ http://www./mydomain.com/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/(.*)$ http://www./mydomain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} http://www./mydomain.co.uk [NC]
#RewriteRule ^tag/(.*)$ http://www./mydomain.co.uk/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/\d{2}/(.*)$ http://www./mydomain.co.uk/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/(.*)$ http://www./mydomain.co.uk/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^news-sitemap.xml /?feed=sitemap-news [L]
# BEGIN W3TC CDN
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# END W3TC CDN
# BEGIN W3TC Browser Cache
<IfModule mod_mime.c>
AddType text/css .css
AddType text/x-component .htc
AddType application/x-javascript .js
AddType application/javascript .js2
AddType text/javascript .js3
AddType text/x-js .js4
AddType text/html .html .htm
AddType text/richtext .rtf .rtx
AddType image/svg+xml .svg .svgz
AddType text/plain .txt
AddType text/xsd .xsd
AddType text/xsl .xsl
AddType text/xml .xml
AddType video/asf .asf .asx .wax .wmv .wmx
AddType video/avi .avi
AddType image/bmp .bmp
AddType application/java .class
AddType video/divx .divx
AddType application/msword .doc .docx
AddType application/vnd.ms-fontobject .eot
AddType application/x-msdownload .exe
AddType image/gif .gif
AddType application/x-gzip .gz .gzip
AddType image/x-icon .ico
AddType image/jpeg .jpg .jpeg .jpe
AddType application/json .json
AddType application/vnd.ms-access .mdb
AddType audio/midi .mid .midi
AddType video/quicktime .mov .qt
AddType audio/mpeg .mp3 .m4a
AddType video/mp4 .mp4 .m4v
AddType video/mpeg .mpeg .mpg .mpe
AddType application/vnd.ms-project .mpp
AddType application/x-font-otf .otf
AddType application/vnd.oasis.opendocument.database .odb
AddType application/vnd.oasis.opendocument.chart .odc
AddType application/vnd.oasis.opendocument.formula .odf
AddType application/vnd.oasis.opendocument.graphics .odg
AddType application/vnd.oasis.opendocument.presentation .odp
AddType application/vnd.oasis.opendocument.spreadsheet .ods
AddType application/vnd.oasis.opendocument.text .odt
AddType audio/ogg .ogg
AddType application/pdf .pdf
AddType image/png .png
AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
AddType audio/x-realaudio .ra .ram
AddType application/x-shockwave-flash .swf
AddType application/x-tar .tar
AddType image/tiff .tif .tiff
AddType application/x-font-ttf .ttf .ttc
AddType audio/wav .wav
AddType audio/wma .wma
AddType application/vnd.ms-write .wri
AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
AddType application/zip .zip
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css A31536000
ExpiresByType text/x-component A31536000
ExpiresByType application/x-javascript A31536000
ExpiresByType application/javascript A31536000
ExpiresByType text/javascript A31536000
ExpiresByType text/x-js A31536000
ExpiresByType text/html A3600
ExpiresByType text/richtext A3600
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
ExpiresByType text/xsd A3600
ExpiresByType text/xsl A3600
ExpiresByType text/xml A3600
ExpiresByType video/asf A31536000
ExpiresByType video/avi A31536000
ExpiresByType image/bmp A31536000
ExpiresByType application/java A31536000
ExpiresByType video/divx A31536000
ExpiresByType application/msword A31536000
ExpiresByType application/vnd.ms-fontobject A31536000
ExpiresByType application/x-msdownload A31536000
ExpiresByType image/gif A31536000
ExpiresByType application/x-gzip A31536000
ExpiresByType image/x-icon A31536000
ExpiresByType image/jpeg A31536000
ExpiresByType application/json A31536000
ExpiresByType application/vnd.ms-access A31536000
ExpiresByType audio/midi A31536000
ExpiresByType video/quicktime A31536000
ExpiresByType audio/mpeg A31536000
ExpiresByType video/mp4 A31536000
ExpiresByType video/mpeg A31536000
ExpiresByType application/vnd.ms-project A31536000
ExpiresByType application/x-font-otf A31536000
ExpiresByType application/vnd.oasis.opendocument.database A31536000
ExpiresByType application/vnd.oasis.opendocument.chart A31536000
ExpiresByType application/vnd.oasis.opendocument.formula A31536000
ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
ExpiresByType application/vnd.oasis.opendocument.text A31536000
ExpiresByType audio/ogg A31536000
ExpiresByType application/pdf A31536000
ExpiresByType image/png A31536000
ExpiresByType application/vnd.ms-powerpoint A31536000
ExpiresByType audio/x-realaudio A31536000
ExpiresByType image/svg+xml A31536000
ExpiresByType application/x-shockwave-flash A31536000
ExpiresByType application/x-tar A31536000
ExpiresByType image/tiff A31536000
ExpiresByType application/x-font-ttf A31536000
ExpiresByType audio/wav A31536000
ExpiresByType audio/wma A31536000
ExpiresByType application/vnd.ms-write A31536000
ExpiresByType application/vnd.ms-excel A31536000
ExpiresByType application/zip A31536000
</IfModule>
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
<FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$">
FileETag MTime Size
<IfModule mod_headers.c>
Header set Pragma "public"
Header set Cache-Control "public, must-revalidate, proxy-revalidate"
Header set X-Powered-By "W3 Total Cache/0.9.2.8"
</IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
FileETag MTime Size
<IfModule mod_headers.c>
Header set Pragma "public"
Header set Cache-Control "public, must-revalidate, proxy-revalidate"
Header set X-Powered-By "W3 Total Cache/0.9.2.8"
</IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
FileETag MTime Size
<IfModule mod_headers.c>
Header set Pragma "public"
Header set Cache-Control "public, must-revalidate, proxy-revalidate"
Header set X-Powered-By "W3 Total Cache/0.9.2.8"
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Trying to add
RewriteCond %{HTTP_HOST} !^img.mydomain.com [NC]
still is getting redirected to www.img.mydomain.com/wp-content/uploads/
Adding some conditions to the standard WP rule-set it's all that is usually necessary. In the current block at the end of the file in the question, it would be something like this:
# BEGIN WordPress
...
RewriteRule ^index\.php$ - [L]
# Add next lines:
RewriteCond %{HTTP_HOST} !^img\.mydomain\.com [NC]
RewriteCond %{REQUEST_URI} !/wp-content/uploads/ [NC]
...
# END WordPress
In this case, there are several rules at the top of the file, before the # BEGIN W3TC CDN comment, that could also be applied to the request as only some of them make sure it is to http://www.mydomain.com, considering the conditions are only valid for the next rule.
So I think it needs at least another exclusion here:
# Add next line:
RewriteCond %{HTTP_HOST} !^img\.mydomain\.com [NC]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Maybe it is necessary to add the same 2 lines to other rules before the # BEGIN W3TC CDN comment, though. I don't know, but this is the general idea.

mod_rewrite to direct some requests to a new directory

I have a website with a frontend and a backend that all run through index.php. To access the back end you would go to http://www.mysite.com/Admin. This will still run through index.php but then connect to the database and go to the correct directory. The backend manages donation information that is collected on the site.
I want to change the front end to WordPress but still collect donation information in the original database and view it from the backend.
Rather than rewrite all the code, I was wondering if there was a way I could use mod-rewrite and place the WordPress files in a separate directory. This way any request that included /Admin as the start would go through the original index.php and any other request would redirect to directory with WordPress.
I originally tried:
RewriteCond %{REQUEST_URI} !^/Admin
RewriteRule ^(.*)$ gpf/$1 [L]
but a request for /Admin just gives me a 404 error.
Thanks in advance for any help.
This is the full .htaccess file
RewriteEngine On
Options -Indexes
# Serve 'gate' as php
<Files gate>
SetHandler application/x-httpd-php
AcceptPathInfo On
</Files>
FileETag MTime Size
AddCharset UTF-8 .xml
AddType video/mp4 mp4 m4v
AddType audio/mp4 m4a
AddType video/ogg ogv
AddType audio/ogg ogg oga
AddType video/webm webm
# redirect all domains (.net, .com, .biz, etc) to .org
RewriteCond %{HTTP_HOST} !^www\.mysite\.org$ [NC]
RewriteRule ^(.*)$ http://www.mysite.org/$1 [R=301,L]
# Route search
RewriteRule ^search$ /search/ [R,NC,L]
RewriteCond %{REQUEST_URI} !^/Admin
RewriteRule ^(.*)$ gpf/$1 [L]
# Route domain plus slash correctly
RewriteRule ^$ /gate/ [L]
# All requests: serve _gate_ as php. 1st arg is requested URL qs preserved
RewriteRule ^([0-9A-Z].*) /gate/$1 [QSA,L]
RewriteRule ^rss\.xml /gate/rss.xml [QSA,L]
# PHP directives - should comment out on production server
php_value display_errors 1
php_value display_startup_errors 1
AddOutputFilterByType DEFLATE text/html application/x-javascript text/css text/javascript text/plain
<IfModule mod_expires.c>
ExpiresActive On
# Manually change filenames for static images. CMS changes names in dyn
ExpiresByType image/gif "access plus 9 months"
ExpiresByType image/jpg "access plus 9 months"
ExpiresByType image/jpeg "access plus 9 months"
ExpiresByType image/png "access plus 9 months"
# Rare changes. manually change filename
ExpiresByType image/x-icon "access plus 9 months"
ExpiresByType image/vnd.microsoft.icon "access plus 9 months"
# PDFs should never change. CMS renames in dyn
ExpiresByType application/pdf "access plus 6 months"
ExpiresByType application/x-pdf "access plus 6 months"
# Frequent changes. ASFU dynamic rename
ExpiresByType text/css "access plus 6 months"
ExpiresByType text/javascript "access plus 6 months"
ExpiresByType application/x-javascript "access plus 6 months"
</IfModule>
Try adding an additional condition:
RewriteCond %{REQUEST_URI} !^/Admin
RewriteCond %{REQUEST_URI} !^/gate
RewriteRule ^(.*)$ /gpf/$1 [L]
And move the rules after all of the /gate/ rules.

Resources