Jump to content

Change default folder for storing images


Frank Vèssia
 Share

Recommended Posts

There isn't an easy way to do that, but you can easily setup your alias from your .htaccess file.

For instance, say that you wanted this URL:

/site/assets/files/123/somefile.jpg

to be accessible at this URL:

/123/somefile.jpg

You could do that with this rewrite rule, placed in your .htaccess file right after the "RewriteEngine On" line:

RewriteRule ^([0-9]+/.*)$ /site/assets/files/$1 [L,QSA]
Link to comment
Share on other sites

mmm...that's good, even It's not what I expected to do. I'm really bad in htaccess...there a way to make this thing more complex? I mean, right now the result it's

http://www.domain.com/pageid/imagefile.jpg

I would like something like

http://cdn.domain.com/pageid/imagefile.jpg

In this way if I want to activate a real CDN in a future, I can do that without change any code, just removing the htaccess directive.

Link to comment
Share on other sites

You would just need to setup the cdn hostname so that it points to the same thing as www (and that your server recognizes it). This is not something you'd setup in htaccess, beyond what's already mentioned. But I would suggest not doing that, as it's not ideal from an SEO perspective to have two hostnames pointing to the same thing.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...