What does MEDIA_URL does now? I am particularly confused after I got "django.core.exceptions.ImproperlyConfigured: The MEDIA_URL and STATIC_URL settings must have different values".
I'd appreciate Django explaining why this is. Regards
MEDIA_URL is used to point to the base URL for user-generated content - uploaded images, files, that sort of thing.
STATIC_URL is used as the prefix for JavaScript, CSS, etc.
The answer doesn't explain the reasoning as to why. One of the nice things about Django is that it doesn't expose the back-end via the url.
Example:
/formmail.pl/search.php
But when it comes to the static files, I guess that doesn't matter.
Very disappointing...
Have a look at note number 2 on this page. There they explain why.
https://docs.djangoproject.com/en/dev/howto/static-files/
Related
I'm migrating an old website to a Wordpress+AngularJS(with Typescript) architecture. We need to keep our SEO by migrating the old URLs to the AngularJS website.
Usually i'd do it using Redirect 301 in .htaccess but it doesn't seem to work with angular. :(
How would you do this?
Best regards.
Nervermind this question, htaccess rewrite rules worked. I think that's becaused I used to write "Redirect 301..." and now it needs "Redirect permanent ..."
Or not, but now it works. ;-)
https://abc.hostingcompany.com/~myusername/img/test.jpg //works, shows the test image
https://abc.hostingcompany.com/~myusername/contact //404 error
http://www.mydomain.com/contact //works as expected, so why dosent #2?
I dont understand how cakePHP 'pages' can be routed to, using SSL.
As I understand it, using relative paths is what you are supposed to do, which I have done. I know there is a component built into cakePHP for security, but for now, just getting the (for example) https version of the contact page link to work is perplexing me.
In my research, I discovered that you can use .htaccess command RewriteBase to convert between the shared version of the URL and the cakePHP version of the url.
I also learnt that relative pathing is important, and that /img/test.jpg is not the same as img/test.jpg (One assumes the root, the other does not).
As long as Im sharing what I found out... (yeah, noob material here... Id like to see any other page on the net with all this in the same spot)
The https version is the same code (pulled from the same folders I mean) as the http code.
Turning on (using) and off https is as simple as a link to https://[yoursite] and http://[yoursite].
And a shoutout to the people at apacheserver.net ripping this off stackoverflow.com. (Its already in the google search results... holy cow)
I'm wondering if it would be okay to keep all of my pages in one folder on a site. and leave only the index.html page in public_html?
I know the URL will be like example.com/pages/about.html but theirs a way to change that right?
This is fine. Theres no reason why it should be a problem. And theres no reason why there should be a problem with your URL being example.com/pages/about.html. If you prefer that, then you do that... its fine.
You can always "mask" your URLs using MOD_REWRITE. Look up mod_rewrite and .htaccess files. You will be able to set a rule to "mask" something.html to pages/something.html. Its not hard to do.
:)
The url structure of my cakephp based site is mysite/cakephp/myapp/index.php/controller/action/input_paramaters
I cannot remove index.php from my url, as I dont have access to httpd.conf file.
Anyways, my question is that I just need to change the url of my homepage to something like http://mysite or mysite/myapp
How would I do that?
Thanks a lot!!
The problem sounds to me that you don't have mod_rewrite enabled or Apache AllowOverwrite is not set properly.
If you don't have mod_rewrite then you cannot change the urls with the pretty ones (provided from CakePHP).
If the AllowOverwrite is not set to On. Then even if you have mod_rewrite enabled, the .htaccess files in your directories doesn't take effect.
I don't know which is worst. Speak with your hosting provider and ask for help.
It is not really clear to me which part of the URL changes. CakePHP routing applies only relative from the cake directory. So if you move from http://example.com/foo to http://www.example.org/bar nothing needs to be changed in Cake.
However you might have hardcoded some img/CSS/JS URL-s that needs some work now. I also use the HTML base tag so my app works perfectly fine under various base URL-s.
I am getting ready to deploy a cakephp app onto the web and i want to move all the assets (img, js, css) to a CDN to increase performance. Is there a way to globally change the location the HTML helper links to assets instead of having to change every link.
Recently I came across this cool helper that accomplishes this task with relative ease. It's called Asset Host Helper and can be obtained from its GitHub repository.
What I liked best about it is that you don't need to worry about changing the location of the assets in your development copy (most likely on localhost) or in your production copy (on the CDN). The helper takes care of it automatically.
Check it out - this might just be the tool you're looking for.
Cheers,
m^e
If the routes and filenames persist, maybe mod_rewrite might be less painful.
RewriteCond %{REQUEST_URI} ^/css/
RewriteRule ^css/(.*)$ http://cd.yourdomain.com/css/$1 [R=301,L]
I had a similar problem, here's how I solved it:
Adding a prefix to every URL in CakePHP
The AppHelper::url() method is the place you should be interested in.
I have a solution but it involves changing the core, I know I know...I have already slapped myself for doing it ;-)
We had a project that was built and then needed a CDN so we just added a bit of code to the HTML and Javascript helpers to assist us.
In the /cake/libs/view/helpers/html.php file add this at line 360
if (Configure::read('Asset.CDN.enabled')) {
$static_servers = Configure::read('Asset.CDN.static_servers');
if(sizeof($static_servers) > 0) {
shuffle($static_servers);
$url = $static_servers[0].$url;
}
}
and in /cake/libs/view/helpers/javascript.php ass this at line 288
if (Configure::read('Asset.CDN.enabled')) {
$static_servers = Configure::read('Asset.CDN.static_servers');
if(sizeof($static_servers) > 0) {
shuffle($static_servers);
$url = $static_servers[0].$url;
}
}
Then in your app/config.core.php file just add the following configuration options
// Static File Serving on a CDN
Configure::write('Asset.CDN.enabled', false);
Configure::write('Asset.CDN.static_servers', array('http://static0.yoursite.com.au/', 'http://static1.yoursite.com.au/'));
Now when you refresh your page each file that is outputted through the html/javascript helper will automatically pick a random static server.
Note that unless you are using absolute paths (including domain names) in your css files you will need to make sure the images are also on the static server.
I know you shouldn't really play around in the core but sometimes it is really just easier.
Cheers,
Dean
I know this is an old question but in case any future people stumble across it in rails 3.1 you can now use
config.action_controller.asset_host = "ATBTracking"
in config/environments/production