Mark
Mark

Reputation: 113

htaccess subdomain to a folder

I have a problem which I can't fix it. I explain you. I have a website like :

admin.myweb.com

So, I have the CSS, Javascripts in a folder called static and the "admin.myweb.com" needs to take that static files in this way:

static.admin.myweb.com

By now I have my "admin.myweb.com" and it runs well but without CSS,Javascript. So I've created a subdomain called "static.admin.miweb.com".

My problem is that I want the website goes to the folder "/instances/myweb/public/static", when it tries to go to static.admin.myweb.com . I've searched a lot and I tried a lot of httaccess codes but no one worked.

Basically I want to say something like : "when you receive static.admin.myweb.com, go to /instances/myweb/public/static".

I'm getting crazy with htaccess! Does anyone know how to do it? :)

Upvotes: 1

Views: 57

Answers (1)

Ravi K Thapliyal
Ravi K Thapliyal

Reputation: 51721

Assuming /instances/myweb/public is your website's root directory, place the following rules in your .htaccess file there:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^static\.admin\.myweb\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/static [NC]
RewriteRule ^(.*)$ /static/$1 [L]

Upvotes: 1

Related Questions