First of all I went through the already asked question related xampp/htdocs/index.php. (eg.: this, this and this and may more other) But still cant reach the proper xampp/index.php file (or other way xampp/index.html). I would like to ask ( those who can reach the the following screen(s), which is displayed at 6:30 in this youtube tutorial ).
Cause I can reach just the following schreen: which is displayed at 16:25 in this youtube tutorial.
the code what I see in my DEFAULT index.php is this:
<?php
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$uri = 'https://';
} else {
$uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/dashboard/');
exit;
?>
Something is wrong with the XAMPP installation :-(
and I tried to modify this line: header('Location: '.$uri.'/dashboard/'); to header('Location: '.$uri.'/**xampp**/');. (in the htdocs/xampp folder I tried to search for the page that is displayed in the tutorial that I linked first).
So ones again I want to reach somehow that screen that is displayed in the first tutorial, I went through all the folders in xampp folder but ther is no any that is redirecting to the proper searched site (most probably the newer versions does not consist this feature/ consist this features some other way).
Anyway I hope someone could help!
If you want to reach the first screen you mentioned
XAMPP Panel & have installed xampp, then just enter in your browser: localhost/xampp
If you want it to come up whenever you type "localhost" in browser then change the index.php /dashboard/ to /xampp/ and it will show in browser if you only type "localhost" without any directory extension.
If you want to show a list of all your xampp/htdocs in your browser window instead of defining a single directory (i.e. like /dashboard) then just rename your index.php & index.htm files (or delete them) then when you type "localhost" or "http://localhost" you will be presented with all the index folders & files from your xampp/htdocs folder in your browser window.. select the local website folder and it will open the corresponding local index file...
Hope that is what you were looking for?
I find the answer for my question. Probably it might be useful for the others that might face the same "problem". HERE IS THE LINK TO THE RELIABLE SOURCE REGARDING IT.
in short: there is no more /xampp/index.php, or as I mentioned "orange/yellow xampp page" (that I and some of us are searching for.), you have to find everything on the phpmyadmin!
Have a Nice day!!! ;)
Related
I am attempting to move my Wordpress website from the subdomain where it is installed:
chicagokaraokenight[dot]com/wordpress
to the root directory:
chicagokaraokenight[dot]com
I've been following the instructions provided by this website.
So, I've:
1) backed up the site
2) I didn't have a site in the root directory but I deleted any redirects I was using
3) turned permalinks to default
4) changed the site address (left the first as /wordpress and changed the second)
5) Downloaded the index.php and .htaccess files, and changed the index.php file to
contains require( dirname( __FILE__ ) . ‘/wordpress/wp-blog-header.php' );
Finished up by uploading, changed back permalinks to the previous settings, and now it's not working. I am assuming I took a misstep when downloading/editing/uploading the files, since the other parts were so self explanatory. After tinkering with it, I'm a little confused what it looked like before and what it should look like now, and it's still not working. Hoping someone can point me in the right direction!
At the moment, when I go to either URL (root or sub), I am getting the following error:
Parse error: syntax error, unexpected '' );' (T_ENCAPSED_AND_WHITESPACE) in /home2/lsaewitz/public_html/index.php on line 17
Currently, both directories (public_html AND wordpress) have both an index.php file and an .htaccess file, and both index.php files have the edits made in step #5 above.
Any ideas as to what I'm doing wrong?
One thing I did notice, is that between a couple different tutorials, some index.php files had:
contains require( dirname( __FILE__ ) . ‘/wordpress/wp-blog-header.php' );
and others just had:
require('./wp-blog-header.php');
without the require('./wp-blog-header.php'); part
Perhaps it is the "curly quote"? If you look at what was posted here you can see it. If that line was copy/pasted from the source, that would be the issue. Try swapping it out for a normal single quote. A lot of blogs and programs like word and outlook like to swap quotes out for curly ones which are not really "quotes" as far as programming is concerned.
I have a PHP site that I have been testing in a subdirectory /dev and everything is working great. I moved all the files over to my root directory and now it doesn't work! I have a config.php file that is handling the code so that I can easily change directories (or so I thought). Working page is here non-working page is here. It looks like all the files are being found but it is not being styled correctly, any troubleshooting tips or anything you guys see? I have been looking at it for days and can't find anything! Please help!
Here is my config.php code
<?php
// these two constants are used to create root-relative web addresses
// and absolute server paths throughout all the code
define("BASE_URL","/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/dev/");
$site_root = $_SERVER["DOCUMENT_ROOT"] . "/dev/";
And...
<?php
// these two constants are used to create root-relative web addresses
// and absolute server paths throughout all the code
define("BASE_URL","/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/");
$site_root = $_SERVER["DOCUMENT_ROOT"] . "/";
Your main issue is that you have /css/styles.css which differs from /dev/css/styles.css. In order to do a clean move and to make sure you don't have 2 different versions while you think they're same:
Delete everything from your root folder except the /dev/ folder.
Copy everything from your /dev/ folder into your root folder.
It's a good idea to learn about Apache's mod_rewrite, and then - use a framework. Isn't maintaining 10's or 100's index.php files a pain?
EDIT 1: In order to disable GoDaddy's caching mechanisms, follow this guide:
Log in to your Account Manager.
Click Web Hosting.
Next to the hosting account you want to use, click Launch.
From the Tools section, click Website Accelerator.
Click Settings.
Click the slider next to Developer Mode so it displays On.
Click Close.
I have not been successful getting my remote server environment to behave like my testing server environment -nor visa versa- in regard to my navigations "include code" that I've included on my various pages (these pages reside inside other folders in the site).
My Menu shows up fine in the pages calling the include to this page this way...
<?php include("../includes/navigation.php"); ?>
But my MAMP testing server seems to want me to also add the root folder in addition to my provided link in each of the menu items, so I altered the link by adding my site root folder, like this...
<a href="/mysite/courses/list.php"
and navigation menu seemed to work, going inside one folder and back out into another (then I realized it was no good when I tested it on my remote server).
I got bad/broken links.
So I changed to something like this for the remote server...
<a href="/courses/list.php"
Links seem to work on the remote, but I needed to fix it so that the code I go with works on both the testing and remote servers...
So, I'm trying to ~~understand/control/and fix~~ my include_once code to provide proper menu navigation for all my various pages whether I am on my testing server or on my remote server and wether I am in one folder or another. Is this possible? And am I approaching this the right way?
(Currently, I have my root folder with an index page, then inside that, I have 3 folders with misc pages inside them, one of these folders (includes) holds my navigation.php page)
I have been searching for how to get my pages (located in various folders) to recognize where they were, in relation to the sites root folder. As a result of searching I concluded to insert this code into the list.php page in my "courses folder"...
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/includes/navigation.php";
include_once($path);
?>
on one of my pages and then tested it in my testing server (MAMP) - but now the menu does not even show up...I also tried...
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "../includes/navigation.php";
include_once($path);
?>
So I am seeking help in understanding - what am I missing in my understanding/execution to get the pages now to show the navigation menu as well as know where it is in relation to the root.
I would welcome any comments to help me understand how to connect the dots to solve this problem. As I read in another post saying to someone else there was a problem with where their site root folder was pointing (that it was pointing to the server root folder, not the site root folder)-
How would I know if this is what my problem is? How do you check this?
I had this same exact problem going on. What I did to solve it was instead of simply using "..includes/nav.php" I used an absolute path to the file. It should look something like this:
"var/www/html/includes/nav.php"
This specifies the exact route to the file. You can find this through your hosting file management page. Log into the file management, find the nav file within the folders, and use the exact url of the file.
I am sure that this is a repost but I cannot find a question the same as what I want to find out. Essentially, whenever I am working offline, all URIs that I use across the site refer to offline locations eg 127.0.0.1/home.html however, when I go to upload the site, these URIs need to be changed to their equivalents eg example.com/home.html and I either need to go through all of the pages and update these references or use some php to insert the correct address at every point where an address is used. At the minute I am using something like this:
Top of every page:
<?php $offline = false; ?>
Link:
Home
But this seems like a poor way to achieve something which should be relatively simple. What is the standard way of keeping these references up to date. I considered using relative links everywhere but that proved to have problems (for example view includes don't work correctly) and I tried setting the base href to the homepage but that threw up other problems.
Any suggestions would be very much appreciated. Thanks.
$server=$_SERVER['SERVER_ADDR'];
// Local
if(strstr($server,'127.0.0'))
{
define('ROOT_PATH','http://127.0.0.1/');
}
// Server
else
{
define('ROOT_PATH','http://www.yoursite.com/');
}
Put this code in php file and include in every page.
And then:
Home
In this case you can put your files in folder too, for example:
define('ROOT_PATH','http://www.yoursite.com/mysite/');
Another way you could do it is using relative paths.
For files in the same directory you'd use ./ and for files above that directory use ../ This works for anchors in HTML and requires and includes in PHP.
As Waygood suggested, it sounds like you need to change your paths from absolute to either site root relative or relative paths. Example: 127.0.0.1/home.html would become just /home.html if using site root relative. Alternatively, if there's a reason why you must include absolute paths, you can set an environment variable on the server or a PHP constant that indicates the environment type and toggle links based on this value. Using environment variables has the added benefit of being able to keep the exact same code base on your dev and production machines and not having to resort to host or IP detection. Here's an example from zend framework's docs guide that I use:
defined('APPLICATION_ENV') || define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
From: http://framework.zend.com/manual/1.12/en/zend.application.quick-start.html
A neat way that I have found to resolve this issue is to amend your HOSTS file so that it points example.com to 127.0.0.1 so that you can refer to example.com everywhere but be redirected to 127.0.0.1 until your development has finished.
Most of my website is in my root directory. And In that directory there is "css", "functions", "images" folder. Everything works fine when I include php files within index.php or any other root file. It includes it fine and executes it fine.
But problem occurres when I made folder "blog". So this is totally new and separate root folder with CMS and its own "root" files. And I try to include css from main root directory or some php files from "functions" folder in main root directory, Everything breaks down. I know I have to include it as ../functions/myfile.com. But this files includes some other files so it just wont work properly and won't be able to include other files properly.
Is there any idea how to fix this problem?
You can get to the root from within each site using $_SERVER['DOCUMENT_ROOT']. For testing ONLY you can echo out the path to make sure it's working, if you do it the right way. You NEVER want to show the local server paths for things like includes and requires.
Site 1
echo $_SERVER['DOCUMENT_ROOT']; //should be '/main_web_folder/';
Includes under site one would be at:
echo $_SERVER['DOCUMENT_ROOT'].'/includes/'; // should be '/main_web_folder/includes/';
Site 2
echo $_SERVER['DOCUMENT_ROOT']; //should be '/main_web_folder/blog/';
The actual code to access includes from site1 inside of site2 you would say:
include($_SERVER['DOCUMENT_ROOT'].'/../includes/file_from_site_1.php');
It will only use the relative path of the file executing the query if you try to access it by excluding the document root and the root slash:
//(not as fool-proof or non-platform specific)
include('../includes/file_from_site_1.php');
Included paths have no place in code on the front end (live) of the site anywhere, and should be secured and used in production environments only.
Additionally for URLs on the site itself you can make them relative to the domain. Browsers will automatically fill in the rest because they know which page they are looking at. So instead of:
<a href='http://www.__domain__name__here__.com/contact/'>Contact</a>
You should use:
<a href='/contact/'>Contact</a>
For good SEO you'll want to make sure that the URLs for the blog do not exist in the other domain, otherwise it may be marked as a duplicate site. With that being said you might also want to add a line to your robots.txt file for ONLY site1:
User-agent: *
Disallow: /blog/
Other possibilities:
Look up your IP address and include this snippet of code:
function is_dev(){
//use the external IP from Google.
//If you're hosting locally it's 127.0.01 unless you've changed it.
$ip_address='xxx.xxx.xxx.xxx';
if ($_SERVER['REMOTE_ADDR']==$ip_address){
return true;
} else {
return false;
}
}
if(is_dev()){
echo $_SERVER['DOCUMENT_ROOT'];
}
Remember if your ISP changes your IP, as in you have a DCHP Dynamic IP, you'll need to change the IP in that file to see the results. I would put that file in an include, then require it on pages for debugging.
If you're okay with modern methods like using the browser console log you could do this instead and view it in the browser's debugging interface:
if(is_dev()){
echo "<script>".PHP_EOL;
echo "console.log('".$_SERVER['DOCUMENT_ROOT']."');".PHP_EOL;
echo "</script>".PHP_EOL;
}
If I understand you correctly, You have two folders, one houses your php script that you want to include into a file that is in another folder?
If this is the case, you just have to follow the trail the right way.
Let's assume your folders are set up like this:
root
includes
php_scripts
script.php
blog
content
index.php
If this is the proposed folder structure, and you are trying to include the "Script.php" file into your "index.php" folder, you need to include it this way:
include("../../../includes/php_scripts/script.php");
The way I do it is visual. I put my mouse pointer on the index.php (looking at the file structure), then every time I go UP a folder, I type another "../" Then you have to make sure you go UP the folder structure ABOVE the folders that you want to start going DOWN into. After that, it's just normal folder hierarchy.
i had the same issue and found a code on https://css-tricks.com/php-include-from-root/ that fixed it
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/common/header.php";
include_once($path);
?>
None of the above answers fixed this issue for me.
I did it as following (Laravel with Ubuntu server):
<?php
$footerFile = '/var/www/website/main/resources/views/emails/elements/emailfooter.blade.php';
include($footerFile);
?>
Try to never use relative paths. Use a generic include where you assign the DocumentRoot server variable to a global variable, and construct absolute paths from there. Alternatively, for larger projects, consider implementing a PSR-0 SPL autoloader.