Forum Moderators: phranque

Message Too Old, No Replies

subdomains to serve static content and rewrite

         

klelugi

3:07 pm on Nov 9, 2010 (gmt 0)

10+ Year Member



Hi everyone,

I face a problem trying to complete a rewriting with some subdomains to serve static content and to avoid other pages of these subdomains to be accessed. Here is the explaination :

I have 2 subdomains to serve static content :

- img.domain.tld
- static.domain.tld

both pointing to same directory as www

Here is what i have in my .htaccess :


RewriteCond %{HTTP_HOST} !^(www|img|static).domain.tld$
RewriteRule ^(.*) http://www.domain.tld/$1 [QSA,L,R=301]


Static content is located in directories : /images/ and /local/

So you can get the static content for example :

- img.domain.tld/local/image.jpg

But you can also have :

- img.domain.tld/one-page.html

How could I also have a 301 to www for all pages not located in /images/ or /local/ ?

I'm afraid i'm stucked...

Many thanks

klelugi

4:12 pm on Nov 9, 2010 (gmt 0)

10+ Year Member



Actually I think I just found, adding those 3 lines before the 1st two :


RewriteCond %{HTTP_HOST} ^(img|static).domain.tld$
RewriteCond %{REQUEST_URI} !^/(local|IMG).*
RewriteRule ^(.*) http://www.domain.tld/$1 [QSA,L,R=301]


Sry to disturb