I'm looking for some advice, I currently use MAMP on locahost and have all of my websites in the htdocs folder. I use Codenighter mainly so when adding in paths for links, images etc I use <?php echo base_url(); ?> which is great for using the same code across live and dev.
I was wondering how I can link through to files from within a javascript file and preserve the paths when taking the site up to the live server?
I'm unable to put in absolute paths such as /controller/ as this doesn't work within the MAMP htdocs folder - I have to use /mysite/controller/ instead.
Is there a good way to preserve the paths when working across the two servers?
You should setup virtualhosts in Apache. By far the easiest way to do this is either get MAMP pro, or get VirtualHost X, the later is what I use. You can certainly setup virtual hosts in the Apache config but VirtualHost X adds the convenience factor.
So for instance if my live site is example.com then I setup a virtual host locally called example.local.
Related
Good morning,
does anyone know how I could configure MAMP (or WAMP) in order to automatically change my project URLs, to localhost without having to search/replace inside my documents (operation I suppose to be a bit gross because possibly altering my code).
My goal is to develop on local while keeping the final and real URLs in my documents.I suppose lot of you have encountered this issue one day :)
In other word, I would like to alternate between online and local more easily.
I a beginner, please consider,
for all the biginners, here's the thing. I've created a config.php file which contains constants: one config file for the local project folder and one for the online server folder.
Inside this config file, I've create a constant (constant are then available everywhere in the project) to define the main URL of the project. e.g.:
define('CST_MAIN_URL',http://www.myproject.com); // for the online config.php file
define('CST_MAIN_URL',http://localhost:8888); // for the local config.php file
Thus, each header or redirection can work with that constant, like:
header('location:' . CST_MAIN_URL . 'index.php');
Then, things must have to do with RewriteEngine in your htaccess file, for instance whenever you must modify the behavior of MAMP/WAMP if an interrogation point or a slash provokes you with its malicious resistance. But, unfortunately RegEx expression must be understood as a basic level for mastering those url rewritings.
Hope it'll helps.
I can view the OL3-Cesium examples from the website online perfectly.
When I view this example, I get the 3D view when I click on enable/disable button.
Now I have downloaded the release folder. When I try to view the same example from the examples folder, the example does not work the same.
This is the output when I open main.html from my system:
I don't know if I am missing something here
The overall problem is that you are running the example directly from the filesystem. The directory needs to be hosted under a web server, even the most basic server will do. For example, if you have python installed, just run python -m SimpleHTTPServer in the root and browse to http://localhost:8000/.
The exact problem you are seeing is that the default imagery provider is configured to use the same URI protocol as the site being visited, i.e. if you are at an http site, it uses http. If you are at https, it uses https. Since you opened directly from disk, you are using file://, which causes the imagery to try and use file:// as well. Since you have no such imagery on your system nothing shows up in the globe.
It is technically possible to use Cesium and Open Layers completely offline, but care must be taken and it looks like that example was not written with it in mind.
When we setup laravel, the default url will have "public" on it.
Example : localhost/laravel/public/users
We know that we always wanted to remove the "public" in our url specially when we go to production.
I searched in the internet and looks like removing the "public" url needs some work to achieve like moving files to other folder, modifying .htaccess, etc...
My question is, whats the purpose of "public" url?
Why doesnt laravel provide an easy way of removing the "public" url..
I know Laravel is popular these days but why give beginners a headache in just removing a part of the url?
Let me know your thoughts
The public directory holds all your files that should be accessible from the outside.
This way nobody can access any other file in your application.
How do you remove the public in your URL? Well you don't "remove" it at all. Instead you should point your domain (virtual host) directly at public (this is called Document Root)
If you don't have the possibility to do that (usually because your on a shared hosting with very restricted permissions) then and only then you need to move files or use a workaround with .htaccess. However if your hoster doesn't allow you to set the document root I would consider to switch to another one...
By the way: This is not really unique to Laravel. A lot of PHP frameworks do it (Zend Framework, Symfony, etc) all have a dedicated directory for files that should be accessible - separated from the framework core and your application.
If you're having trouble setting up your development environment correctly, you should try out Laravel Homestead. It's a pre-configured Vagrant box that makes it very easy to get your site locally up and running (also comes without public in your URL!)
When you make your site's root point to the public folder, e.g. www.mysite.com points to /path/to/laravel/public, there are a few advantages.
Your files outside of public, like your .env with your passwords cannot be accessed doing things like www.mysite.com/../.env and other common "exploits" are prevented just by taking this simple approach.
It's quite a common pratice in other frameworks too, not only Laravel or PHP.
I'm looking for a way to set the DocumentRoot while browsing local file:// sites.
My situation:
I have a copy of my web server on my local machine and sync it via rsync to the server. I'm looking for a way to check these site (while offline, so I can't just sync them) without installing a local web server.
I can open the files, but all links beginning at the DocumentRoot are broken.
What I'm looking for:
A switch like "chromium --doc-root=/home/user/website/http/" or similar would be perfect.
Is there anything like this?
Thanks for your help.
AFAIK, I don't think Chromium provides such options to specify document root for file scheme, which is also obey the file URI scheme (http://en.wikipedia.org/wiki/File_URI_scheme).
For your case, I think it's better to use a simple http server (e.g. if you have python, just use SimpleHTTPServer).
Ff file scheme is used, you still have to append --allow-file-access-from-files to avoid permission restrictions.
This question already has answers here:
How do I run a file on localhost?
(7 answers)
Closed 4 years ago.
I have a site directory for html (dreamweaver CSS3) with lots of subdirectories that contain HTML files for a number of drop down menus. They work fine where they are, but they all have menus that are JavaScript and could be kept in a separate file. So, I want to use Include. I don't want to have to FTP my files to HostGator every time I want to test the includes. I want to have this on my local machine. So, I am attempting for the first time to setup XAMMP and then run my html files (site) on localhost, so I can see what they look like before ftping everything to HostGator and putting it live.
I tried copying the main site folder to htdocs, and then copying the path to the file I want to run in front of the localhost in Firefox, but it gave me file not found:
http://localhost/xampp/PL_20080923/0-Sections/000-ComingSoon/PHPTestComingSoonNMBT-Test.html
Do I have too many subdirectories? Why isn't the file being found? It is there.
Tried this too:
http://localhost/xampp/htdocs/PL_20080923/0-Sections/000-ComingSoon/PHPTestComingSoonNMBT-Test.html
No go.
http://localhost/ should be equivalent to xampp/htdocs/ (i.e. the same files should be accessible but served by the webserver.) This is the document root. So for example on a normal windows xampp installation http://localhost/index.html should serve c:\xampp\htdocs\index.html.
Did you try http://localhost/PL_20080923/0-Sections/000-ComingSoon/PHPTestComingSoonNMBT-Test.html ?