Cakephp multiple applications in root folder - cakephp

I have two apps and I want to access the first app by http://localhost/ (Note: no app1 folder specified here) and the second by http://localhost/app2/. How can I set this up?

why not working with virtual hosts?
thats the right way to do it:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
you can have as many "vhosts" as you want. this will also enable you to work locally as you would live (on the webserver).

Related

Localhost points to different address

I have an app developed with CakePHP and it is working just fine on my local machine. Now, I wanted to develop another app with CakePHP. I installed cake in a different folder, configured vhost and server block and did everything like for the first app. I created an empty app, just basic controller and view and when I type the address for the second app I get the first app!!! Weird thing is that all links are working and when I click I get in browser url like secondapp/companies but the content is firstapp/companies. Once more, the second app is empty, no controllers, views and models, just a basic one. Then I did all that in htdocs, and the same problem occurs (none of the apps wasn't in htdocs, but in folders on E partition).
Can someone please give me some help before I kill myself?
Thank you...
If the problem is not on the database configuration, maybe cache problems ? Try it on a private browser/incognito ?

How to show Image from local drive in Angular JS [duplicate]

I'm trying to retrieve a picture from my file system after a good storage,(instead of putting it in the database I copy it to the disc and i put the path to the db)
I had store the picture to c:\images\ folder and supposing that the name the complete path is c:\images\mypic.jpg
when I try to retrieve it a set the img src attribute to <img src="c:\images\mypic.jps"> by using some java code
in the browser console I found this error Not allowed to load local resource: file:///C://images//mypic.jpg
Question: how to fix these path problem ? where Should I store the pictures ? and from where should I retrieve them ?
sending tag <img src="c:\images\mypic.jpg"> would cause user browser to access image from his filesystem.
if you have to store images in folder located in c:\images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.
But what you use to create your application? is it pure servlet? Spring? JSF?
Here you can find some info about, how to do it.
In Chrome, you are supposed to be able to allow this capability with a runtime flag --allow-file-access-from-files
However, it looks like there is a problem with current versions of Chrome (37, 38) where this doesn't work unless you also pass the runtime flag --disable-web-security
That's an unacceptable solution, except perhaps as a short-term workaround, but it has been identified as an issue:
https://code.google.com/p/chromium/issues/detail?id=379206
You have Two alternatives :
First one is to create a ServletImageLoader that would take as a parameter an identifier of your image (the path of the image or a hash) that you will use inside the Servlet to handle your image, and it will print to the response stream the loaded image from the server.
Second one is to create a folder inside your application's ROOT folder and just save the relative path to your images.
Many browsers have changed their security policies to no longer allow reading data directly from file shares or even local resources. You need to either place the files somewhere that your tomcat instance can serve them up and put a "regular" http url in the html you generate. This can be accomplished by either providing a servlet which reads and provides the file putting the file into a directory where tomcat will serve it up as "static" content.
The concept of http location and disk location is different. What you need to do is:
for uploaded file summer.jpg
move that under a known (to the application) location to disk, e.g c:\images\summer.jpg
insert into db record representing the image with text summer.jpg
to display it use plain <img src="images/summer.jpg" />
you need something (e.g apache) that will serve c:\images\ under your application's /images. If you cannot do this then in step #2 you need to save somewhere under your web root, e.g c:\my-applications\demo-app\build\images
This error means you can not directly load data from file system because there are security issues behind this. The only solution that I know is create a web service to serve load files.
Here is a simple expressjs solution if you just want to run this app locally and security is not a concern:
On your server.js or app.js file, add the following:
app.use('/local-files', express.static('/'));
That will serve your ENTIRE root directory under /local-files. Needless to say this is a really bad idea if you're planning to deploy this app anywhere other than your local machine.
Now, you can simply do:
<img src="/local-files/images/mypic.jps"/>
note: I'm running macOS. If you're using Windows you may have to search and remove 'C:\' from the path string
Do not use ABSOLUTE PATH to refer to the name of the image for example: C:/xamp/www/Archivos/images/templatemo_image_02_opt_20160401-1244.jpg. You must use the reference to its location within webserver. For example using ../../Archivos/images/templatemo_image_02_opt_20160401-1244.jpg depending on where your process is running.

Access base URL of main site in another site in Drupal 7

I have setup multisite in Drupal 7 and need to access theme settings and base url (test.com) of a main site in test1.test.com. How Can I do this one?
For example:
Main site: test.com<br>
Multisite: test1.test.com<br>
Multisite: test2.test.com <br>
likewise.
Folder structure:
sites/all/themes/testtheme/<br>
sites/test1/themes/custom_theme/test1<br>
sites/test2/themes/custom_theme/test2<br>
Thank you in advance.
I assume you should be using a different settings.php with a different DB for each sub-domain site, and in this case you can't access the variables of other sites into another site. However, there are two ways to get the main site base_url in other sites.
First, you could add a configurations variable through settings.php like $conf['main_site_base_url'] in individual settings.php OR the other way, if you are using a shared codebase, you can set this variable in custom module hook_init() or hook_boot() [whichever works with your setup] with this variable_get('main_site_base_url','test.com').
Once the confiuration variable set into the system you could get this using the variable_get function like variable_get('main_site_base_url','').
For inheriting the theme settings I would suggest to go with a sub-theme option as explained in this post.

Redirect script making image referencing impossible

I have a site that I run off the back of another site. In order to save on hosting etc. the domain points to a script and depending on the url that is in the address bar it redirects accordingly to a subfolder which holds the separate sites. I am happy with this and it works a treat. So when it hits url 1 it goes to "www.domain1.com/url1/Home/Index" and when number 2 is typed in it goes to "www.domain2.com/url2/Home/Index". url1 and url2 being the subfolders.
The problem comes when i am developing another site that is going off the back of the original. i have the site developed in vs and am about to release and obviously all of the image urls, script urls etc are completely wrong as they don't take into account the subfolder within the site. they all used /images/site/image1.jpg etc. this means that they are looking from the root and not from my subfolder url.
is there a simple way of implementing this so that i can develop it using vs and not have to change every image reference every time i release code?
i realise this probably has an incredibly easy answer to my problem - i just can't seem to find anything that fits.
Any suggestions?
slight addition to this - when my site loads it loads to the default page - and therefore when i use ../images/site etc this works when the url contains Home/Index, but not when it hits it on the default url which doesn't include the folder and page qualification.
Just noticed this was left unanswered. When referencing in MVC you need to use the tilde (~) to reference the route of the application. So in my instance i have two sites and using the tilde notation if referenced the route of the application, of which each were specified as different routes.

alias/ short form of address of silverlight app on hosting

I host my Silverlight app in commercial hosting, but to get it I must put in address field in browser all physical path to aspx file ;/
http://netmajor.home.pl/SecretaryAppNav.Web/SecretaryAppNavTestPage.aspx
It is some way to configure application that I can write short address of my page ?
If netmajor.home.pl is under your control, you could simply move a copy of the SecretaryAppNavTestPage.aspx page to the root of your website and rename it to something simpler.
Then you could access it via http://netmajor.home.pl/SL.aspx or whatever you want to call it.
There is no code behind for that page (or you could use the matching .html test page that you will also find in your project).
If you were to make it your default page (index.aspx or default.aspx) you could just use http://netmajor.home.pl/
Hope this helps.

Resources