简体   繁体   中英

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? :)

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM