I currently have my index.html file within a public_html folder and my PHP config files in a separate resource folder which is on the same level at the public_html folder. When setting up my Homestead.yaml file, I have to point to the exact directory where my index.html folder is. This is causing issues when I need to call a script from the other folder. Have I set up my folders wrong, or is my yaml file wrong?
Thanks!
Related
I am using a shared host. Inside my shared host public_html, I have a folder named project1. This folder contains the files for my main site.
I want to create a new folder (e.g. Project2) for my new Laravel 8 application. I've tried putting all my file inside public_html. It is working when I visit the site using the example.com/project2/public/index.php URL format. But the problem with this is that my important file like the .env, will be public.
I've also tried this but when I tried to run the project, it gave me a 500 error.
Try changing the name of server.php file to index.php and copy .htaccess file from public folder to same location where server.php
1.
Uploaded my files to 000webhost. I placed all files from the public folder to public_html then I created a folder named laravel and there I uploaded all other files. This is the structure of my directory:
laravel
app
bootstrap
config
....
public_html
index.html
.....
2.
In my index.php file, I already changed some things to these
require DIR.'/../laravel/bootstrap/autoload.php';
$app = require_once DIR.'/../laravel/bootstrap/app.php';
3.
I also changed the .env file and the database.php in the laravel/config folder
Problem:
I am now able to access the home page of my site, but when I click my links to the other pages error 404 shows up.
How do I fix this?
And how do I access the routes in my api.php ?
Thanks!
Your includes seem fine.
Be sure you also uploaded the .htaccess file located in /public (in your /public_html). The file name starts with a dot so it's commonly hidden.
The purpose of this file is to indicate Apache how to map URLs to real files (in this case, everything should point to index.php)
Try changing the index.php file. Change it as the following:
require __DIR__.'/laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/laravel/bootstrap/app.php';
This should solve the problem.
I have a development server at dev.mysite.com and I am working with coda and git to make commits and pushes to the repo which has a developmenet branch that points to my dev domain.
The file structure as of right now is this. As of right now does anyone see anything that I should reconsider changing. I'm asking this because of having a public_html inside the dev folder or what. With this setup currently when I load dev.mysite.com it shows the index of / which shows .gitignore, .git, and public_html.
../
/dev
/mysite.com
.git
.gitignore
/application
/public_html
/assets
index.php
/system
/mysecondsite.com
/application
/public_html
/assets
/index.php
/system
/sites
/mysecondsite.com
/application
/system
index.php
Does anybody have any ideas?
If you want to have a development environment and a production environment. While having the core files for CI outside of a public_html. You have to redefine your document root. I assume you are using a server the comes with cPanel as your means of administration for your server.
So that said, you go into your cpanel and where you defined your dev subdomain, you should be able to edit the document root folder. So on the server in your dev folder you will add a public_html like I gather you already have from the example above. And with your current folder settings for dev you add /public_html to the string that is the folder path now.
Once you do that allow a minute or two for it to delegate to the server from cPanel. And move your folders around as you see fit.
From there, you find the root index.php and open that up, find the references for your application folder and your system folder and change them to match the paths they should be looking for now. Likely using relative paths.. ie: ../../applications for example. Save your index.php
Assuming you have done everything in general correct your copy of CI should load correctly as it did when you didnt have everything in the folders split up like you want..
I have a batch of files in
/home/***/construct/
which I have symlinked to the subdomain 'http://sampleaccount.mywebsite.com' so that the '/constuct/' directory appears in that subdomain's specific directory tree.
The files within '/construct/' are master page-layout files that include PHP includes to a '/bodyCopy/' directory within the 'sampleaccount' subdomain. For example:
<?php include("bodyCopy/copy-content.php"); ?>
BUT...
I keep getting an error on my Web page that indicates PHP is searching for the 'copy-content.php' file in the '/bodyCopy/' directory in /home/*/construct/ (which does not exist) instead of in the '/bodyCopy/' directory located within 'http://sampleaccount.mywebsite.com', as in...
http://sampleaccount.mywebsite.com/bodyCopy/copy-content.php
Therefore, how do I make the symlinked master page-layout files search the current directory TO WHICH THEY ARE LINKED search for the '/bodyCopy/' directory in the 'sampleaccount' subdomain instead of it searching the root?
The caveat is that the '/construct/' directory in root will be symlinked to multiple subdomain accounts, each with their own '/bodyCopy/' directories, so I cannot use a hard link in the master page-layout files.
Thanks in advance for any solutions provided. -- Jet
<?php include("/rootfoldername/bodyCopy/copy-content.php"); ?>
or
<?php include("../bodyCopy/copy-content.php"); ?>
Am trying to use a config file for a database and rating script but the problem is the config file is in this directory :
website.com/include/config.php aka websitename/include/config.php
The rating script needs the config and is accessed like this:
include_once("config.php");
I want the config to be in:
"/files/website/"
A directory level up from the website root folder.
I have been trying with:
"../files/website/" and other variations but can not figure out how to link them.
I have managed to put one config file and access it, but with this ajax rating script the only way for it to work is to have the config in the /include/ folder next to:
rating_process.php - has this link : include("inc/config.php");
rating_functions.php - has this link : include_once("config.php");
rating_total_functions.php - has this link : include("inc/config.php");
Hope i've explained myself here
Right, looking at my hosting now:
$_SERVER['DOCUMENT_ROOT']; outputs this: /foldy/homepages/11/username/htdocs/webbysite
My index file is located at: /foldy/homepages/11/username/htdocs/webbysite/index.php
The included rating script is located in: /foldy/homepages/11/username/htdocs/webbysite/include/
I want the config to be in /foldy/homepages/11/username/htdocs/secretfiles/config.php
Am trying to some how go out of: webbysite folder and then into secretfiles (sibling folders)
I have tried adding ../ and so on, but am missing something obviously :(
Try
$configLocation = $_SERVER['DOCUMENT_ROOT'].'../files/website/config.php';
include_once($configLocation)
but the problem is the config file is in this directory
it is not a problem at all.
just keep it as is.
Concerning your particular problem, your problem is that you don't know where you want to put your file. /files/website/ is not likely a right path and it is apparently not one level high from webroot.
So, first of all make your mind about the right path to the directory and it's relative position to the web root
if you are concerned about security ( because your config file contains the db details ) i would place the db config file outside the site root folder and then require_once('../../dbConfig.php') from the script that's creating xml or json for your ajax
more exactly ...
your site folder might be here: /var/www/html
set a virtual host (done differently on Linux and Windows) and point your domain to a sub folder inside /html so that the new path to the site root is /var/www/html/site.
then place your config file in /var/www/html and call it from your scripts inside your /site folder using require_once('../dbConfig.php)`.
your db details are outside the site folder