I'm trying to config the path using WSGIScriptAlias after loading wsgi module succesfully with this line:
WSGIScriptAlias / /home/patipol/RTG-Likitomi/likitomi/apache/django.wsgi
It works properly for my application but this also caused phpmyadmin at http://localhost/phpmyadmin cannot be found. If I'm not mounting at root so change it to:
WSGIScriptAlias /django /home/patipol/RTG-Likitomi/likitomi/apache/django.wsgi
Phpmyadmin come back to work again but many links in my code cannot be found such as:
<iframe id="map" name="map" src="/inventory/" frameborder="0" style="width:100%; height:500px; margin-top:35px; margin-left:0px;" scrolling="no"></iframe>
Location at "/inventory/" cannnot be found. I have to change it to "/django/inventory" to make it works. The problem is there are many links in my code specified like this. Is there another way to solve this by not changing every links in my code? Thank you.
To still have it mounted at root yet have static files and PHP still work, use technique described in:
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive
instead of WSGIScriptAlias.
For the case of using WSGIScriptAlias and mounting at sub URL, you should not be hard coding absolute URLs in your templates in the first place. Instead you should be using something like 'url' template tag to generate the URL. This way you change things around, or mount application at different mount point and they will all automatically adjust. See:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#url
and:
https://docs.djangoproject.com/en/1.3/topics/http/urls/#topics-http-reversing-url-namespaces
and the 'reverse' function for doing same in code.
Related
I would like to call script and css from site root.
I have a dev environment using wamp so my route is localhost/mysite/js/script.js.
My prod environment will be mysite/js/script.js.
I would like to call script from root, what should be the route if I'm not in the root folder and don't want to use ../?
The reason for that is I imagine a much more complex arborescence and I want to avoid excessive ../../../../[...] and I'm wondering if there is something for this.
Let's say I've a page in pages/contact.html and I want to call scripts/contact.js
If I call scripts/contact.js : 404 because I'm in the pages folder.
If I call /scripts/contact.js : It will work in mysite.com but won't in local because I need to call /mysite/scripts/contact.js.
Thanks for your help.
As #peter-krebs mentioned, the cleanest solution would be to spin up an isolated web server to develop this project in. You could use XAMPP as suggested but a containerized approach using Docker might be more flexible.
Alternatively, you can add a <base href="/mysite/"> tag to the head of all your pages and write all your paths as relative to that directory. You will have to specify all of your resource paths (js, css, images, links) using this relatively-absolute method though. Meaning you won't be able to directly access relative resources in the same directory anymore.
For example, if pages/contact.html needed the file pages/contact.js you could not use the path ./contact.js from within contact.html. You would have to specify pages/contact.js even though those files are in the same directory.
When you move the site to production, just change the base to <base href="/"> and everything will continue to work as expected. You could even do this in an automated way by adding the following script to your document head.
<!DOCTYPE html>
<html>
<head>
<script>
let base = document.createElement('base');
base.href = (document.location.host == 'localhost') ? '/mysite/' : '/';
document.currentScript.replaceWith(base);
</script>
...
So I'm trying to access my root directory in HTML but when I use / it is not working. So for example I'm trying to get my navigation css by doing:
<link rel="stylesheet" href="/nav.css">
The weird thing is, it works perfectly fine when I am using VS Code with the live server extension, but I just recently noticed when I run the index.html file alone none of the links starting with the / work. I know this is the issue too, because when I take away the / in the above line, it works perfectly fine again (only for the homepage page in the root directory already).
As Quentin points out, if you're loading the index.html file locally without a server, the root directory will be the root of your file system. If your requirement is for the index.html file to work locally on your professor's machine without a web server, you should use relative paths.
In order to traverse back up your file system from the current file, you can use paths that start with ../
when I run the index.html file alone none of the links starting with the / work
If you are running index.html alone then the links starting with / will be relative to the root of your file system.
The browser doesn't (and can't) know which directory represents the root of your web site project.
Use a web server. Load the data over HTTP.
Try this:
./nav.css
It (I mean, ./) loads files in the same directory of index.html, same as nav.css. With VS Code, I bet ./nav.css should work for the live preview too: using an external HTTP server (such as http-server on Node.js) helps, because it takes the current directory (where index.html is) as the root and you can easily reach /nav.css. Without a live server, the relative path could be reached as I said with ./nav.css (a typical *NIX path) or simply nav.css without slashes on Windows.
As others have indicated then the reason it's not working is because by loading the file directly you are now loading it as a local file rather than a file on website, and thus your URL base (Your /) is now referring to the root of your local file system. Which would likely be C:\ on a windows system or your actual root / on a *nix system.
To actually solve your issue I would suggest one of the following solutions:
Just always run the project over HTTP through a server.
Go through your project and change all of your paths to be relative paths. You might be able to use a find replace in your editor to do this.
Use a <base> tag to specify what the base href of your web page should be.
If you can't use a server and just have a single HTML file then it might be quickest to use fix 3. You can probably get away with using <base href="."> to make the base the current directory of your index.html file which, I suspect, will be a drop in solution to make things work as they did before.
In future best consider this and how you are going to run the file, and what your URLs are going to be relative to. It's a wrinkle that can be easily missed nowadays that the tools we use in development are so good at hiding the details of how websites are actually deployed.
I don't think <base> is a good idea.
It will change the base href in the whole page, which might cause problems when using other links or section navigation.
I migrated my magento website to a different server, following the steps described here. Everything went smoothly, except for the fact that when I load the page, the CSS won't load, and I just get the page in plain text.
I used firebug and noticed that the path the system is using to get to the CSS file doesn't exist in the FTP server. It starts with the 'minify' folder, which makes me think that something might be cached from the previous server.
An example:
my_site_url/minify/1281335374/skin/frontend/default/hellouno/css/styles.css
This path doesn't exist, not even in the previous server, so I'm thinking maybe these files are supposed to be generated on the fly? I'm really confused, any help will be very appreciated!
In my case, the problem was a missing Slash "/" at the end of the domain.
Use the following to get both rows:
SELECT * FROM core_config_data WHERE path = 'web/unsecure/base_url' OR path = 'web/secure/base_url';
Then update them manually and make sure the domain has it's final "/", otherwise it will merge the domain name with the following folder name.
You can check whether this is your condition if when doing inspect, you see a wrong path to CSS and JS.
Correct Config:
Incorrect Config Results in:
Remember to clear the var/cache folder.
I'm going to assume you cleared your cache out. If "not having CSS" makes this hard to do via the admin, just delete the
var/cache
folder.
Sometimes giving the CSS (or Javascript) merge settings a quick toggle from on, to off, to on again will force Magento to recalculate the paths.
System -> Developer -> CSS Settings
If you can't access this in the Admin, change the value manually in the database table core_config_data (identified by the path column having the value dev/css/merge_css_files), clear your cache and reload your page
Sounds like an issue with your .htaccess file. Minification rewrites are handled there. If you haven't already, make sure your .htaccess file came over in the transfer, and make the appropriate changes if directories or anything else has been changed.
Thanks its helped me i just forget to place / in the end of the path.
Before:
Base URL http://mywebsitename.com
After:
Base URL http://mywebsitename.com/
Its solved all skin/css and admin problem. Cheeers
I solved the issue, by changing the merge css options in the backend to no
It was a bit difficult to navigate through backend without css but managed to get there!
System > Configuration > Developer > CSS Settings
If you haven't changed your site information (url and such) in the backend (or in the database) after the migration, this is the likely problem.
http://www.siteground.com/tutorials/magento/magento_configuration.htm#base_url
for the database:
in the core_config_data table
change key "web/unsecure/base_url" to your site base url ex. http://yoursite.com
good luck!
Experienced same problem once.
The solution:
I'd forgotten to put trailing slashes at the end of my base_urls when I'd updated them
System > Configuration > General > Web > Unsecure
Base URL http://mybaseurl.com/
System > Configuration > General > Web > Unsecure
Base URL https://mybaseurl.com/
If you're Admin section is out of bounds you can also set this value in the database in the table core_config_data
Fields: web/unsecure/base_url and web/secure/base_url
Also: Remember to flush your cache after doing this.
Check permissions for the folders like app/etc, var, media folders. Try to give 755 permissions to those folders. Recently I have faced the same problem and I tried with this. Then my site works fine.
Change Permission Of Skin And Media Containing All Folder TO Give Permission 755 And File TO 644
Mine was also the forward slash ( / ) at the end of the url in the sql database. Cleared Cache and it worked perfect.
One answer that has not been given yet that turned out to be the solution to my problem:
When transferring the Magento store from 1 host to another, what usually isn't copied over is the VirtualHost entry. In my case I had to manually recreate this and wrongfully added AllowOverride None. This should be AllowOverride All in order for .htaccess files to be read and processed.
I have a simple html file that consists of a gifv video which does not play on Google Chrome while if I enter the code at w3schools, it renders properly which makes me confused.
I have checked the other previous solutions to fix the gifv problem but it is still not rendering on my html file.
HTML script
<blockquote class="imgur-embed-pub" lang="en" data-id="91S22q6" data-context="false"><a href="//imgur.com/91S22q6">
View post on imgur.com</a>
</blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
I had the same problem as you- gifvs will not load locally when using imgur's embed code. After a lot of head scratching I figured out that if you load your html file over a python server, the gifs will render. It's really easy to do, it's just a one line command. Here's an article explaining how to do it:
http://www.pythonforbeginners.com/modules-in-python/how-to-use-simplehttpserver/
here's the basic summary:
"An advantage with the built-in HTTP server is that you don't have to install
and configure anything. The only thing that you need, is to have Python installed.
That makes it perfect to use when you need a quick web server running and you
don't want to mess with setting up apache.
You can use this to turn any directory in your system into your web server
directory.
To start a HTTP server on port 8000 (which is the default port), simple type:
python -m SimpleHTTPServer [port]"
http://s.imgur.com/min/embed-controller.js refers to window.location.protocol. If you are browsing a resource served from file://, this is going to break the expectations of that script.
That means you need to serve this via http:// or https:// to work.
I deployed my static HTML website to Heroku using this tutorial (http://www.lemiffe.com/how-to-deploy-a-static-page-to-heroku-the-easy-way/) and my pictures won't show up ? It works perfect locally so I don't really understand why it doesn't when it's deployed on Heroku ?
I've also looked up every other solution that stackoverflow has to offer and nothing worked for me. Any help is really appreciated
Here is the order of my folders/files (folders are capitalized):
-RESUMEAPPCOPY
-home.html
-portfolio.html
-index.php
-aboutme.html
-PUBLIC
-IMG
-JS
-CSS
Code for image:
<img src="/Users/erv/Desktop/MyProjects/resumeappcopy/public/img/PennUnitedWebsite.PNG" alt="PUSA-Icon" class="img-rounded" style="height: 300px;"/>
Whenever I inspect the element on Heroku it says :
Failed to load resource: the server responded with a status of 404 (Not Found)
and where the picture is supposed to be I have the typical broken image link picture
Your <img> tag is pointing to an absolute path that exists on your local filesystem, but does not exist for your Heroku app. Instead, provide a relative path (relative to the HTML file invoking the <img> tag, that is) to your image asset, commit the change to version control, then redeploy to Heroku.
Assuming that your public directory is actually nested within the resumeappcopy directory, the following path should work:
<img src="public/img/PennUnitedWebsite.png" alt="PUSA-Icon" class="img-rounded" style="height: 300px;"/>
UPDATE:
Note that the cited asset URL points to an asset with the file extension PNG in uppercase. However, the file's actual file extension is png – in lowercase (see here). Your local filesystem is probably insensitive to case when looking up a resource – but Heroku is not. You'll need to ensure that you're properly invoking the correct casing for resources when you deploy to Heroku.
I had the same problem and found the problem to be the capitalized file type ('.PNG'). I believe Heroku is searching for files without any .toLowerCase() function applied. Which means you must request an exact match between your markup and your file with capitalization being important.
This wasn't a problem on my local node / express server but became an issue after deploying to Heroku. Some of my images were showing up but others were getting 404 errors (i.e. the ones with capitalized file types). The smart thing to do is to always make your file types are lower case.
I changed this:
<img src="public/img/PennUnitedWebsite.PNG" alt="PUSA-Icon" class="img-rounded" style="height: 300px;"/>
To this:
<img src="public/img/PennUnitedWebsite.png" alt="PUSA-Icon" class="img-rounded" style="height: 300px;"/>
I hope this helps anybody that came across this issue as it confused me for at least an hour. Good luck!
You are giving an absolute path to the image:
/Users/erv/Desktop/MyProjects/resumeappcopy/public/img/PennUnitedWebsite.PNG
The image works locally, but cause this directory exists on your local machine; it does not exist on Heroku.
You need to use a path that is relative to the directory being served by Heroku / your server:
/../PUBLIC/img/PennUnitedWebsite.PNG
(this assumes that your link exists in an HTML file in the RESUMEAPPCOPY directory)
The only answer that hits the nail right on the head: Heroku is case-sensitive!
Took me half a day to figure that out!
Well , whenever your Web-page's contain HTML, CSS and JavaScript , so follow just 2 steps :
1) Make one file give name as index.html (keep evreything in it) ex:script,stylesheet & body.
2) Now, change these file, copy and paste these same file but change domain to index.php
Then deploy on a Heroku , Keep your images downloaded in one folder with index.html
Hence this method will help you to deploy your Web-Pages
In summary, to properly load the images:
1) Use relative url path relative to index.html
2) image file extension needs to be png instead of jpg, and write it in lower case, eg: "cat.png"
Heroku is case sensitive with images so make sure all your images are set to lowercase names.
Referencing from the frontend view "catPicture.png" won't work but "catpicture.png" will work. It's a big quirk! Took me hours to solve this.
If the image has a large size it will not load on the Heroku on a free version.
You can resize the image in an image editor (ie: paint) to reduce the size but it will also reduce quality.
Then push by the following commands
git add .
git commit -m "resize"
git push heroku master
It should work 👍👍
I had the same problem: case-sensitive png files. But to fix the issue I suggest lowerCasing them AND changing the name of the image file. This way you can be safe (and more organized in your versions) when you commit them to git and push to heroku
I had the same problem.
change the jpg image file to png.
worked for me
I had similar problem recently on Windows OS. Pictures loaded properly when tested localy, but on heroku some of the pictures were loading while others where not. And pictures were in the same folder! My paths and script were correct, but as others mentioned it was a case-sensitivity problem. I renamed the files, uploaded again but it didn't help. Why? Because changing the letter case is not recognized as real change for git on windows. To properly load newly named files i did those steps (all commands can be found at heroku tutorial pages):
Destroy heroku app and make a new one
Delete .git folder from your directory
Create new git remote for your app
Push all your files again
This way, heroku files will have names of files the way you like. Worked for me.