Static files from a subdomain

Developer
Şundan Hungary
Tem 2017 tarihinden beri üye

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
Şundan Sweden
May 2013 tarihinden beri üye
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
Şundan Sweden
May 2013 tarihinden beri üye
tim

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

Developer
Şundan Hungary
Tem 2017 tarihinden beri üye

Yes Tim, I want to solve this.

tim
Founder
Şundan Sweden
May 2013 tarihinden beri üye
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
Şundan Hungary
Tem 2017 tarihinden beri üye

Hi Tim!

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

tim
Founder
Şundan Sweden
May 2013 tarihinden beri üye
tim

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

Developer
Şundan Hungary
Tem 2017 tarihinden beri üye

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

tim
Founder
Şundan Sweden
May 2013 tarihinden beri üye
tim

What does your browser console say?

tim
Founder
Şundan Sweden
May 2013 tarihinden beri üye
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?

Bu konu uzun süredir aktif olmadığı için kapatıldı. Konuya mesaj göndermek mümkün değil.
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.