Static files from a subdomain

Developer
Depuis Hungary
Membre depuis juil. 2017

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
Depuis Sweden
Membre depuis mai 2013
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
Depuis Sweden
Membre depuis mai 2013
tim

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

Developer
Depuis Hungary
Membre depuis juil. 2017

Yes Tim, I want to solve this.

tim
Founder
Depuis Sweden
Membre depuis mai 2013
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
Depuis Hungary
Membre depuis juil. 2017

Hi Tim!

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

tim
Founder
Depuis Sweden
Membre depuis mai 2013
tim

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

Developer
Depuis Hungary
Membre depuis juil. 2017

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

tim
Founder
Depuis Sweden
Membre depuis mai 2013
tim

What does your browser console say?

tim
Founder
Depuis Sweden
Membre depuis mai 2013
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?

Ce fil de discussion a été fermé en raison d'une longue inactivité. Il n'est pas possible de publier dessus.
Ce site n'utilise aucun cookie ni aucune technologie de suivi tierce. Nous pensons pouvoir faire mieux que les autres et nous nous soucions vraiment de votre vie privée.