jamie Developer Lähettäjä Hungary Jäsen alkaen heinäk. 2017 jamie 2 heinäk. 2021 13:42 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 Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 2 heinäk. 2021 16:36 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 Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 2 heinäk. 2021 17:38 Are you looking for a solution to load images etc from a static subdomain?
jamie Developer Lähettäjä Hungary Jäsen alkaen heinäk. 2017 jamie 3 heinäk. 2021 10:28 Yes Tim, I want to solve this.
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 3 heinäk. 2021 17:19 Create a subdomain that works as an alias domain for your website. 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>```
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 3 heinäk. 2021 17:43 I made this addon for you https://www.litecart.net/en/addons/395/static-content-domain
jamie Developer Lähettäjä Hungary Jäsen alkaen heinäk. 2017 jamie 4 heinäk. 2021 10:16 Hi Tim! Thank you very much for inviting everything from the static domain. Only the fontawesome icons do not appear anywhere.
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 4 heinäk. 2021 13:53 This means there could be a CORS issue. Are you on nginx or apache? .htaccess is for apache
jamie Developer Lähettäjä Hungary Jäsen alkaen heinäk. 2017 jamie 5 heinäk. 2021 09:13 I use a Litespeed web server that handles .htaccess modifications.
jamie Developer Lähettäjä Hungary Jäsen alkaen heinäk. 2017 jamie 5 heinäk. 2021 09:27 It has this css code that appears, but the product sharing icons don't work, @import url("https://use.fontawesome.com/releases/v5.14.0/css/all.css");
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 5 heinäk. 2021 16:49 What does your browser console say?
jamie Developer Lähettäjä Hungary Jäsen alkaen heinäk. 2017 jamie 5 heinäk. 2021 17:20 Access to the "https://domain.com" font from "https://static.domain.com/ext/fontawesome/fontawesome-webfont.woff2?v=4.7.0" has been blocked by CORS policy: There is no "Access-Control-Allow-Origin" header in the requested resource.
tim Founder Lähettäjä Sweden Jäsen alkaen toukok. 2013 tim 6 heinäk. 2021 20:50 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?