HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Need help with .htaccess

R_JR_J Ex-FanboyMunich Moderator

To be honest, that question has nothing to do with Vanilla, though it can come that it will be helpful for someone trying to build up a CDN. That's what I'm trying to do - but not with Vanilla.

I've created an account at MaxCDN, created a subdomain cdn.example.com that points to a subdomain at MaxCDN. That's the start. Now I have to add something to my .htaccess so that every file in example.com/images/articles/www.example.com/images/articles should be loaded from cdn.example.com/images/articles. But I even fail at using a subdomain. cdn.example.com leads me directly to www.example.com

Can anyone tell me how to change that so that I can at least try if the subdomain is really working?

The Rewrite block of my .htaccess looks like that:

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.example\.de$ [NC]
RewriteRule ^(.*)$ http://www.example.de/$1 [R=301,L]

RewriteRule shopware.dll shopware.php
RewriteRule files/documents/.* engine [NC,L]
RewriteRule application.yaml engine [NC,L]
RewriteRule images/ayww/(.*) images/banner/$1
RewriteRule sitemap.xml(.*) shopware.php?controller=SitemapXml
RewriteRule templates/.*(css|js)$ engine/backend/php/sCacheTemplate.php?file=$0 [NC,L]
RewriteRule engine/core/php/sAjaxSearch.php$ engine/backend/php/sAjaxSearch.php [NC,L]
RewriteRule engine/core/php/campaigns.php$ engine/backend/php/campaigns.php [NC,L]

RewriteCond %{REQUEST_URI} !(engine\/|images\/|files\/|templates\/|\.js$|\.css$|\.jpg$|\.png$)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ shopware.php [PT,L,QSA]



Best Answer


  • R_JR_J Ex-Fanboy Munich Moderator

    Thanks for your answer! I guess that must be write but it seems as if there's something wrong with my hoster: even copying your code with example.com into my .htaccess file doesn't break the picture links on that side. So obviously it is not working although it must...

  • LincLinc Former Staff Detroit Admin
    edited August 2014

    @R_J said:
    even copying your code with example.com into my .htaccess file

    You mean in place of the cdn.example.com, or something else?

    That was simply my best guess; rewrite rules are like dark incantations that require testing and cursing to make work. :expressionless:

  • R_JR_J Ex-Fanboy Munich Moderator

    I've copied the exact line right below "RewriteEngine on". I've played around with it and before I have done very similar things. But no combination of domain/no domain, path with regex/path with an absolute match has given me any results. I was hoping I have done something wrong with those switches, but now I'm convinced it is the fault of the hoster. I'll write him a message and see what I get in return.

  • LincLinc Former Staff Detroit Admin

    OK. As an FYI, I don't think you can use the full domain in the regex (nor is there any reason to). It's only matching based on the path, iirc. I never have, anyway.

  • R_JR_J Ex-Fanboy Munich Moderator

    By the way: that way of using a CDN is complete bullshit because it will double the http requests per picture. 1) look at the original place, 2) get the rewrite and make an additional http request. Pfff... I wish I had done better research right from the start...

Sign In or Register to comment.