Closed (won't fix)
Project:
Parallel
Version:
6.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Sep 2009 at 22:02 UTC
Updated:
3 Feb 2011 at 11:21 UTC
WITH www
Before
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
After
RewriteCond %{REQUEST_FILENAME} !\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn1.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn2.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn3.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
WITHOUT www
Before
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
After
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn1.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn2.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn3.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
I might be able to use RewriteCond %{HTTP_ACCEPT} . Would work with .php images... but I think javascript requests don't send out an accept header. This also redirects links to images on your site from outside sources from cdn to normal.
RewriteCond %{HTTP_REFERER} !^.*example\.com [NC]
RewriteCond %{HTTP_ACCEPT} !(.*image.*)
RewriteCond %{HTTP_ACCEPT} !(.*css.*)
RewriteCond %{HTTP_ACCEPT} !(.*javascript.*)
RewriteCond %{HTTP_HOST} ^cdn1.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn2.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cdn3.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
OR for non www redirect. Pick above or below.
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Comments
Comment #1
mikeytown2 commentedreferer doesn't work very well
Comment #2
mikeytown2 commentedBetter idea would be to redirect by file extension for javascript/css & HTTP_ACCEPT for images...
Untested below (haven't tested "|" OR selector):
I think I can make it so you don't need example.com in the rules, but don't have the time to tinker around with it.
Comment #3
mikeytown2 commentedmarking this a dup of this #579624: Redirect non image/css/js requests from cdn1.example.com to example.com or www.example.com
Comment #4
mikeytown2 commentedComment #5
dropbydrop commentedI want the same for a cdn domain existing on same server/folder structure used just for images.
I use the following:
RewriteEngine on
RewriteCond %{HTTP_HOST} cdn.example.com [NC]
RewriteCond %{REQUEST_URI} !\.(png|gif|jpg|jpeg)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
When I put this in .htaccess it works, but it does not work if I put it in setup of virtual host in apache.
edit:
it seems that when there is allowoverride all and htaccess, rewrite rules at apache config files are ignored totally, right?
Comment #6
wim leersThis won't be implemented.
See #933942: Merge Parallel and CDN modules: migration path to find out how this module will evolve.