Reputation: 2074
Here is my server structure:
folder_in_root
another_folder/not_root_here
another_folder/nested_script.php
index.php #in root
one_script_in_root.php #in root
I have the following function running in ALL the scripts of the server, whether in root or not:
function notify(){
(...)
if ( !(strpos($_SERVER['SCRIPT_NAME'], 'index.php')) && ($feedback["connect_time"] == 0 || $feedback["http_code"] == 404)){
exit("<meta http-equiv='refresh' content='0' ;url='../index.php'>");
}
}
This function does not refresh the page if it is inside index.php, which is good, and heads to index.php if not inside index.php WHEN the original script is NOT on root. So, this script works in another_folder/not_root_here
, another_folder/not_root_here
, index.php
but FAILS in one_script_in_root.php
because it keeps refreshingone_script_in_root.php
over and over again instead of sending the user to index.php
. I can't figure out why this happens. Can someone help me please? tyvm.
Upvotes: 0
Views: 1844
Reputation: 444
The best solution would be to just replace index.php with your domainname/ip. This makes the function work on whatever directory you call it.
<meta http-equiv="refresh" content="0; URL=\\www.mydomain.com">
Upvotes: 0
Reputation: 11125
This meta refresh has a wrong syntax
<meta http-equiv="refresh" content="0; URL=../index.php">
would be correct
Upvotes: 2
Reputation: 862
index.php is located at root of your domain, so just redirect to /
url="/"
Btw, you can use location header instead.
Upvotes: 1