Static files from a subdomain

Developer
Tól től Hungary
Tagság júl. 2017 óta

Hello!

I want to invoke all static files from a subdomain. I don't want a cdn service, just a subdomain.
Eg static.yourdomain.com

I tried to invite this:
<? php include vmod :: check (FS_DIR_APP. 'includes / boxes / box_region.inc.php'); ?>

<? php include 'https://static.yourdomain.com/includes/boxes/box_region.inc.php'); ?>

But it doesn't work. Is there a solution for this?

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
tim

Your code has syntax errors. But you can't include a remote file over the HTTP protocol. Use the server side file system path instead.
This will not work because that file requires app_header to be executed first.

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
tim

Are you looking for a solution to load images etc from a static subdomain?

Developer
Tól től Hungary
Tagság júl. 2017 óta

Yes Tim, I want to solve this.

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
tim
  1. Create a subdomain that works as an alias domain for your website.

  2. Try this vQmod:


<modification>
 <id>Static Domain</id>
 <version>1.0</version>
 <vqmver required="true">2.4.0</vqmver>
 <author>litecart.net</author>
  <file name="includes/library/lib_document.inc.php">
    <operation error="log">
      <search position="before"><![CDATA[
      if (class_exists('stats', false)) {
      ]]></search>
      <add><![CDATA[
    // Static Domain
      if (substr($_SERVER['REQUEST_URI'], 0, strlen(WS_DIR_ADMIN)) != WS_DIR_ADMIN) {
        $static_domain = 'https://static.mydomain.com';
        $GLOBALS['output'] = preg_replace('#("|\(|\'| )(https?://'. preg_quote($_SERVER['HTTP_HOST'], '#') .')?(/[^"\'\) ]+\.(a?png|css|eot|gif|jpe?g|js|less|map|otf|svg|tiff|ttf|woff2?)(\?[^\'\)"]+)?)("|\)|\'| )#', '$1'. rtrim($static_domain, '/') .'$3$6', $GLOBALS['output']);
      }
      ]]></add>
    </operation>
  </file>
</modification>```

3. Put this in your .htaccess

```    # Deny access to non-static content
    RewriteCond %{HTTP_HOST} ^static\.
    RewriteCond %{REQUEST_URI} !\.(a?png|css|eot|gif|jpe?g|js|less|map|otf|svg|tiff|ttf|woff2?)$ [NC]
    RewriteRule ^ - [R=403,L]```

And

```    # Allow cross domain access to fonts
    <IfModule mod_headers.c>
      <FilesMatch "\.(eot|ttf|otf|woff2?)$">
        Header set Access-Control-Allow-Origin "*"
      </FilesMatch>
    </IfModule>```
Developer
Tól től Hungary
Tagság júl. 2017 óta

Hi Tim!

Thank you very much for inviting everything from the static domain.
Only the fontawesome icons do not appear anywhere.

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
tim

This means there could be a CORS issue.
Are you on nginx or apache? .htaccess is for apache

Developer
Tól től Hungary
Tagság júl. 2017 óta

I use a Litespeed web server that handles .htaccess modifications.

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
tim

What does your browser console say?

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
tim

So static.domain.com should be replaced by the domain you have in mind. Did you go for the modification here in the forum thread or the add-on?

Ezt a témát a hosszú inaktivitás miatt bezártuk. A hozzászólás nem lehetséges.
Ez a weboldal nem használ cookie-kat és nem használ harmadik féltől származó nyomkövetési technológiát. Úgy gondoljuk, hogy jobban tudjuk csinálni, mint mások, és tényleg gondolunk az Ön magánéletére.