Is there a way I can setup nginx to serve static content from static.example.com - without having to modify all my php files to reflect where to get the images from?
I was hoping there was some trick I can do in the nginx conf files.
this probably belongs on ServerFault, but I think you're looking for something like this:
rewrite ^(/assets/)(.*)$ http://static.example.com/$2 permanent;
So if your PHP files refer to a file /assets/images/background.png, the calls to that file will be directed to static.example.com/images/background.png
Hope this helps!
Related
I would like to know is it possible to remove index.html, info.html from the URL?
Also, what to add in
Start page
to make a start page like facebook.com. (Without facebook.com/index.html(php)?
You use this:
Start page
And you can set rewrite rules and stuff depending on server and access.
Wanna learn more, google for apache and rewrite rules and .htaccess if you are on an apache server. Else you are probably on a nginx server.
I'm completely new to XAMPP, and don't know much more than HTML and CSS. I've put my website into a subfolder in htdocs called test. In my HTML, I have relative links that look like /test/path/to/image.jpg.
I was planning on uploading the subfolder test to a server using FTP. My question is, will I encounter any problems because of the way I have my links formatted? When my website is live, I'd like for the URL to look more like example.com/path/to/image.jpg rather than example.com/test/path/to/image.jpg. Is it better to use ../ to define my paths instead?
I've seen some similar questions that required people to use the .htaccess file, but I can't find that/don't know how to use it. Again, sorry for my total lack of knowledge on this; I'd be super grateful for any help.
/test/path/to/image.jpg
Isn't a relative path/link - it is absolute, meaning the web server would try to serve the file from http://www.example.com/test/path/to/image.jpg. If you would like that file to be served using a relative URL, you should use:
path/to/image.jpg
Which will serve the file relative to the page that is requesting it. If the requesting page is in the test directory, and document root is the test directory, the server would deliver http://www.example.com/path/to/image.jpg.
I am currently making a website, and have a folder containing CSS3 and HTML5 code in it. When I click on the index.html file, it opens up a local file and I can see my design and text in it. However, I am not sure how to have my website "point" to the index.html file, so it shows the content that is in the file. (I bought the domain with GoDaddy).
Thanks for the help!
Make Sure the directory does not have any other default files like default.php,default,html,etc and also there should be only one index file. if there is any index.php it will overtake index.html. Please make your question more clear and tell use which hosting are you using.....
Check documentation of the company that provides you hosting - the server has a list of files it looks for on disk in a given order. Only thing you need to do is to rename you file to match server's "lookup table".
Relevant part of configuration of the most popular web servers:
apache: https://httpd.apache.org/docs/current/mod/mod_dir.html
nginx: http://nginx.org/en/docs/http/ngx_http_index_module.html
Just getting going with Jekyll - running it on Debian, base install, base config.yml.
I am serving some static resources from a url ( and folder named the same )
/assets
How would I go about setting some cache headers on stuff in there ?
Done much searching and reading the docs and not much finding. Config setting ??
Hope I can be pointed in the right direction.
Cheers!
Rob
Headers, gzipping, and such would be handled by your web server, and the exact configuration mechanism and details will differ from server to server.
One great alternative is the s3_website script (https://github.com/laurilehmijoki/s3_website). It syncs your static files with S3 from AWS and can set headers and also gzip selected files. It works really nice and does all with one command.
Ok.. total noob question.
I always thought that when I saw a URL like www.siteName.com/designs/ .. that PHP or some CMS was at work. I know how filepaths work, etc. , but I always thought that generally simple sites were in a "flat" system
index.html
about.html
gallery.html
/css/
/js/
/images/
So today I just had one of those aha moments. And I now have my main directory with index.html, but a few folders (students/ , shows/, etc) In each of these I have an index.html page. This should essentially be the same as having students.html, shows.html in my main directory, correct? Except it would give me the kind of URL format I would like to have, yes? (eg mysite.com/students)
Problem is, my browser just shows me the directory. I see a file list with my index.html there, but the page is not loading automatically.
What stupid thing am I doing wrong? (I'm on localhost if that makes a difference). I thought that if your browser enters a directory it should load index.html (isnt that why people put blank index pages in a directory? To stop the contents from being listed?)
You have to configure your web server to do this. If you're running apache, it's done with a line in .htaccess like this:
DirectoryIndex index.php index.html home.html something-else.php
Those filenames are listed in order of priority, so if you have both index.php and home.html in the same folder, index.php is loaded. Usually this is set up by default, but servers can be configured a lot of ways.
If you use XAMPP on localhost, it will display the list of files instead of the index files. You can change it though, look at :
http://www.astahost.com/info/tiflds-setting-default-xampp-web-server.html
If you use something else then XAMPP there probably will be an settings somewhere to set the default file to load as well. Just Google it :)